3

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">
  <%= f.submit "Save" %>
</div>
  <% end %>

Art and Lit are both strings and are attr_accessible in dplan. Thanks for your help!

steffi2392
  • 1,345
  • 3
  • 19
  • 19
  • Check [this question](http://stackoverflow.com/questions/4721058/undefined-method-merge-for-2fixnum) out, it might be the same problem. – dee-see Aug 25 '11 at 18:53

2 Answers2

6

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/
Adnan
  • 2,949
  • 4
  • 29
  • 45
2

Have you tried:

<%= f.check_box :Art %>
<%= f.check_box :Lit %>

Some examples for you to consider.

acco
  • 550
  • 6
  • 13