Uncategorized – PullMonkey Blog http://pullmonkey.com Wed, 16 Nov 2011 21:09:19 +0000 en-US hourly 1 https://wordpress.org/?v=5.6 Formgen 0.3.0 and some generated examples http://pullmonkey.com/2011/11/17/formgen-030-and-some-generated-examples/ Thu, 17 Nov 2011 00:01:03 +0000 http://pullmonkey.com/?p=57676 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.

]]>
Form Gen – ruby on rails gem http://pullmonkey.com/2011/11/16/form-gen-ruby-on-rails-gem/ Wed, 16 Nov 2011 04:38:31 +0000 http://pullmonkey.com/?p=57670 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.

]]>
VIN API – ignore checksum validation http://pullmonkey.com/2011/10/28/vin-api-ignore-checksum-validation/ Fri, 28 Oct 2011 15:55:35 +0000 http://pullmonkey.com/?p=57615 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:

]]>
Capybara does not trigger JS change event with celertiy driver http://pullmonkey.com/2011/03/03/capybara-does-not-trigger-js-change-event-with-celertiy-driver/ http://pullmonkey.com/2011/03/03/capybara-does-not-trigger-js-change-event-with-celertiy-driver/#comments Thu, 03 Mar 2011 22:52:58 +0000 http://pullmonkey.com/?p=57599 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.

]]>
http://pullmonkey.com/2011/03/03/capybara-does-not-trigger-js-change-event-with-celertiy-driver/feed/ 1
Rack application timed out during boot – capybara http://pullmonkey.com/2011/03/03/rack-application-timed-out-during-boot-capybara/ http://pullmonkey.com/2011/03/03/rack-application-timed-out-during-boot-capybara/#comments Thu, 03 Mar 2011 03:04:28 +0000 http://pullmonkey.com/?p=57597 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.

]]>
http://pullmonkey.com/2011/03/03/rack-application-timed-out-during-boot-capybara/feed/ 1
Cucumber and Pickle – find_latest_model! http://pullmonkey.com/2011/03/02/cucumber-and-pickle-find_latest_model/ http://pullmonkey.com/2011/03/02/cucumber-and-pickle-find_latest_model/#comments Wed, 02 Mar 2011 16:39:07 +0000 http://pullmonkey.com/?p=57593 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?

]]>
http://pullmonkey.com/2011/03/02/cucumber-and-pickle-find_latest_model/feed/ 2
A Million Trees – Ecobold.com http://pullmonkey.com/2011/02/23/a-million-trees-ecoboldcom/ Wed, 23 Feb 2011 02:24:15 +0000 http://pullmonkey.com/?p=57583 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.

]]>