PullMonkey Blog


17 Nov

Formgen 0.3.0 and some generated examples


Formgen generates views in erb and haml based on these keywords: has_many, belongs_to, accepts_nested_attributes_for, and has_attached_file. It follows best practice and standard patterns so you don't have to. Here is example of its usage:

Doing this

rails generate skizmo:form Foo

Generates this

app/helpers/foo_setup_helper.rb

app/views/foos/new.html.erb

app/views/foos/edit.html.erb

app/views/foos/_form.html.erb

app/views/foos/_bar_fields.html.erb

app/views/foos/_baz_fields.html.erb



That's it:

Ok, so I say that, but there are a few things to note. First, this probably only works with Rails 3, given some of the calls I make for figuring things out. Next, you'll want to yield :head, somewhere in your layout so that the content_for :head that loads the add and remove jQuery will be useful. Finally, you should note that the nested attributes are only processed from the first level, but that will soon change. Anyway, enjoy it and if you have any problems, just let me know.


No Response Filed under: Uncategorized
16 Nov

Form Gen - ruby on rails gem


I've always dreaded doing the view code for nested attributes, setting up the helpers, the javascript, partials etc. Just so tedious, so I thought, I'd try my hand at a form generator. This generator takes a class and then processes all the nested attributes of that class's has_many's and belongs_to's to generate the typical pattern of form partial and field partials you find here.

Yah I did ruby syntax-highlighting ... so not the best for something like that, but eh ... it'll do.

The formgen gem is a 0.1.0 starting point, but has worked for all the things I've needed. If you're feeling brave give it a shot:

# In your Gemfile -
gem 'formgen'
# then from your rails projects -
rails g skizmo:form SomeClass

That outta do it.


No Response Filed under: Uncategorized
28 Oct

VIN API - ignore checksum validation


It's been mentioned a few times that there should be a way to skip the checksum validation. This means if the check digit calculation generally fails, VIN API will continue to process the VIN to see if there is a "like" VIN match. So here it is:


03 Mar

Capybara does not trigger JS change event with celertiy driver


I've never had so much to write about ... these last few days with cucumber and culerity have been great ...
Just a couple days ago, I was using cucumber and culerity to test some select box interaction and none of my tests were passing but everything I did manually worked as expected.
After tons of digging through the various gems, I found out that only a click event is actually being triggered, no change event.
So this is what I came up with for the step definition -

See improvement?, let me know.


1 Response Filed under: Uncategorized
03 Mar

Rack application timed out during boot - capybara


I've been doing lots and lots of cucumber testing these days. I would get this error every so often and there's really search results for it, so here's what you do -

1) Edit your features/support/env.rb file
2) Add "Capybara.server_boot_timeout = 50" #... the default is 10
3) Save and rerun your tests.


1 Response Filed under: Uncategorized
02 Mar

Cucumber and Pickle - find_latest_model!


I've been working with cucumber, capybara and pickle quite a bit recently and came across a problem.

I wanted to be able to tag a record for later reuse.  The way pickle does this is to use find_model, which gets the very first record and associates this to the tag you use to name the record.

I want to get the latest record, the most recent record and tag that for reuse, there does not seem to be a way to do this currently.

So here is what I did.

Added this to my features/support/pickle.rb:

And can now use this as my step definition:

And now I have a reference I can use later for things like show and edit pages:

Then a product: "test" was just created
And I should be on product: "test"'s page

This has really helped my tests, maybe there is an alternative to having to do this?


2 Responses Filed under: Uncategorized
23 Feb

A Million Trees - Ecobold.com


Ecobold - Million Trees

I recently completed a project for EcoBold.com to help support their mission to plant 1,000,000 trees (that's 1 Million). They are asking for support from the community and came up with an idea to help business owners (and the like) kill two birds with one stone. That is - EcoBold decided to take the million dollar homepage approach and offer businesses (and individuals) a way to promote their business while at the same time planting trees and helping our environment.

Supporting the cause is simple, you visit the million tree project page and select a group of pixels to purchase. Each pixel is 1 dollar and helps plant one tree. After selecting your group of pixels, you are presented with a slide down modal to provide your company's information, things like the url, an image, a tag line, etc. After that confirm your selection, make your purchase and own a piece of history.


No Response Filed under: Uncategorized