Ruby

geocoder forked & uploaded to github

For a Rails project I'm working on I started using the geocoder gem for zipcode validation. Unfortunately the release that was available via gem was flaky and would often crash if you queried for just a zipcode instead of a full address. With some digging around I discovered that the code in its subversion repository had some fixes applied that hadn't been pushed out to the gem, and after testing them it sure enough was much more robust. Well, this sounded like an excellent use of github!

Tags: 

Reminder - rails forms with file uploads

Just a quick reminder for myself: if you're doing a form that is uploading files, remember to add :multipart => true to the form tag, e.g.:
[source:ruby]
< % form_for(:product, :url => products_path(@product), :html => {:multipart => true, :method => :put }) do |f| %>

< %= f.file_field :photo %>

< % end %>
[/source]

Tags: 

Making a form reset button in Rails

Rails doesn't have reset_tag to automatically make a form reset button, instead you have to take a slightly different route. To make a form reset button in Rails you simply do this:
[source:ruby]
< %= submit_tag("Start Over", { :name => 'reset', :id => 'reset_button', :type => "reset" }) %>
[/source]
which will create the following:
[source:html]

[/source]

Tags: 

Pages

Subscribe to Ruby