Ruby on rails Formtastic+;嵌套类别
我有一个文章模型和一个类别模型。类别充当树 构建选择列表的最佳方法是什么,以允许管理员从选择列表中选择一个类别,以便稍后将其与文章关联Ruby on rails Formtastic+;嵌套类别,ruby-on-rails,nested-sets,formtastic,Ruby On Rails,Nested Sets,Formtastic,我有一个文章模型和一个类别模型。类别充当树 构建选择列表的最佳方法是什么,以允许管理员从选择列表中选择一个类别,以便稍后将其与文章关联 semantic_form_for(@article) do |f| f.input :title, :as => :string f.input :content, :as => :text f.input :category, :collection => #what should go here ? end 试试这个: f.
semantic_form_for(@article) do |f|
f.input :title, :as => :string
f.input :content, :as => :text
f.input :category, :collection => #what should go here ?
end
试试这个:
f.input :category, :as => :select, :collection => Category.all
或者,您可以将其指定为(从文档中):
试试这个:
f.input :category, :as => :select, :collection => Category.all
或者,您可以将其指定为(从文档中):
8年后,你有没有想过p8年后,你发现了吗P