Rails has_many through form with checkboxes and extra field in the join model

后端 未结 3 1912
长情又很酷
长情又很酷 2020-12-01 03:08

I\'m trying to solve a pretty common (as I thought) task.

There\'re three models:

class Product < ActiveRecord::Base  
  validates :name, presence         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 03:39

    I just did the following. It worked for me..

    <%= f.label :category, "Category" %>
    <%= f.select :category_ids, Category.order('name ASC').all.collect {|c| [c.name, c.id]}, {} %>
    

提交回复
热议问题