Rails has_many :through and collection_select with multiple

后端 未结 1 704
再見小時候
再見小時候 2020-12-05 03:17

I have the following problem using a has_many :through many-to-many relation in a multi-select via collection_select :multiple => true. I have Suppliers who deliver many Ing

相关标签:
1条回答
  • 2020-12-05 03:33

    I've got the problem solved. In this case, using fields_for was the error. The solution is using a collection_select, like this:

    <%= collection_select(:ingredient, :supplier_ids, 
                  Supplier.all(:order=>"name ASC"), 
                  :id, :name, {:selected => @ingredient.supplier_ids, :include_blank => true}, {:multiple => true}) %>
    
    0 讨论(0)
提交回复
热议问题