steffi2392
steffi2392

Reputation: 1355

Using checkboxes in rails

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!

Upvotes: 3

Views: 5325

Answers (2)

Adnan
Adnan

Reputation: 2967

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/

Upvotes: 6

acco
acco

Reputation: 550

Have you tried:

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

Some examples for you to consider.

Upvotes: 2

Related Questions