Jump to content

The ultimate community for Ruby on Rails developers.


Collection of checkboxes in Rails 2.3.5

  • Please log in to reply
No replies to this topic

#1 amirmiller



  • Members
  • 2 posts

Posted 13 April 2014 - 03:19 PM



I have a question regarding an older version of rails (2.3.5)

I have a table with cases

I have a table with segments (4 segments)

And I have a join table mapping case_id to segment_id (each case can have multiple segments).


My forms needs to have a checkbox for each segments and to be able to save and show what is selected.

I am able to save the state of the checkboxes using the code below.

What I don't understand is how to populate the form so all checkboxes (even the one's which are not checked) are shown on the screen???


<% f.fields_for :customer_engagement_business_segment do |ff| %>
     <%= ff.check_box :_delete,{:checked => true},'0','1' %>
     <%= ff.label ff.object.ce_business_segment.name %>
     <%= ff.hidden_field :ce_business_segment_id %>
     <%= ff.hidden_field :customer_engagement_id %>
<% end %>
How do I first draw all of the checkboxes and then make the selcted as checked?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users