Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Formtastic+;嵌套类别_Ruby On Rails_Nested Sets_Formtastic - Fatal编程技术网

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