I've never used checkboxes in rails before and can't figure out what I'm doing wrong. When I try to load my page, I get an error that says NoMethodError in Dplans#show, undefined method "merge" for "Art":String
Here is the code for my checkbox form on the Dplans
show
page:
<%= form_for @dplan, :url=>{ :action=>"update_distribs" } do |f| %>
<%= f.check_box :Art, 'Art' %> <b>Art</b> <br/>
<%= f.check_box :Lit, 'Lit' %> <b>Lit</b> <br/> <br/>
<div class="actions">
开发者_StackOverflow中文版 <%= f.submit "Save" %>
</div>
<% end %>
Art and Lit are both strings and are attr_accessible
in dplan
. Thanks for your help!
The second parameter to FormBuilder.check_box is a hash of HTML options.. The string you specified is not necessary. Try this instead:
<%= f.check_box :Art %> <b>Art</b> <br/>
<%= f.check_box :Lit %> <b>Lit</b> <br/> <br/
Have you tried:
<%= f.check_box :Art %>
<%= f.check_box :Lit %>
Some examples for you to consider.
精彩评论