How to pre-check checkboxes in formtastic

前端 未结 4 824
天命终不由人
天命终不由人 2021-02-04 03:14

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

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-04 03:43

    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
    

提交回复
热议问题