I have a form I\'m trying to set up ... Users can have many posts, and each post can have many people watching it.
The Watch model is set up polymorphically as \'watcha
For anyone else having the same issue:
<%= f.input :some_input, :as => :boolean, :input_html => { :checked => 'checked' } %>
If you need the state of the checkbox to reflect the value of :some_input
<%= form.input :some_input, :as => :boolean, :input_html => { :checked => :some_input? } %>
In your model..
def some_input?
self.some_input ? true : false
end
Set the boolean attribute's value to 'true' in the controller before your render the form. That should make Formtastic default the checkbox to 'checked'.
For multiple check boxes, this way:
<%= f.input :tags, :as => :check_boxes, :collection => some_map.collect { |c| [c[:name], c[:id], {:checked=> tag_ids.include?(c[:id])}] } %>