活动管理员,首先填充第二个下拉列表中的一个

我正在使用单词来进行类别映射。 单词可以映射到类别或类型。 在数据库中,我有单词表,类别表,类型表和名为word_categories的连接映射,其中包含word_id,cat_type(具有类别或类型的值),cat_id(如果cat_type是类别,则cat_id对应于类别表,或者如果cat_type是类型,cat_id对应于类型表)。

在主动管理关键字_categories.rb我有

form do |f| f.inputs do if f.object.new_record? f.input :word, as: :select, collection: Word.unmapped.pluck(:word) f.input :cat_type, as: :select, :collection => ["Type", "Category"] if true #here i have to give some logic to select on the basis of the value selected in the first drop down f.input :cat_id, as: :select, :collection => Type.pluck(:name) else f.input :cat_id, as: :select, :collection => Category.pluck(:name) end end 

结束时间结束

我跟着SO问题 ,但我不明白,我如何将值从控制器返回到活动的管理rb文件

我是jquery的新手

Interesting Posts