Handle check box forms with an `:has_many :through` Record Association

后端 未结 1 996
心在旅途
心在旅途 2021-01-06 07:17

I am using Ruby on Rails 3.0.7 and I would like to use check box fields in my view files (that is, for new and edit forms) with an :has_many :through Record Ass

相关标签:
1条回答
  • 2021-01-06 07:54

    The link Dogbert supplied is a good way of doing it manual. If you however decide to use Simple Form you get that functionality build in.

    Using the example from the previously mentioned article you would do:

    <%= simple_form_for(@user) do |f| %>
      <%= f.association :groups, :as => :check_boxes %>
      <%= f.submit %>
    <% end %>
    

    This example is of course very simplified but it should work. Good luck!

    0 讨论(0)
提交回复
热议问题