Skip to content

Instantly share code, notes, and snippets.

@danielevans
Created October 14, 2011 18:06
Show Gist options
  • Save danielevans/1287851 to your computer and use it in GitHub Desktop.
Save danielevans/1287851 to your computer and use it in GitHub Desktop.
Broken rails form helper code
Controller:
@estimate = Hashie::Mash.new({
:same_address => 1,
:cc_number => nil,
:shipping_address => Hashie::Mash.new,
:billing_address => Hashie::Mash.new
})
View:
<%= form_for @estimate, :as => :estimate, :action => "post", :url => "/orders" do |f| %>
<%= f.check_box :same_address,{ :disabled => "disabled" } %>
<% end %>
result:
<input name="estimate[same_address]" type="hidden" value="1">
<input checked="checked" disabled="disabled" id="estimate_same_address" name="estimate[same_address]" type="checkbox" value="1">
This works, but it seems like the helpers should be doing this:
<%= hidden_field_tag 'estimate[same_address]', '0' %>
<%= check_box_tag 'estimate[same_address]', "1", @estimate[:same_address].to_s == "1", :disabled => "disabled" %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment