Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
897 views
in Technique[技术] by (71.8m points)

jquery - Active Admin, populate one of the second drop down after first

I am using a word to category mapping. A word can be mapped to a category or a type. In database, I have words table, categories table, types table and a join mappings called word_categories which contains the word_id, cat_type (having value either category or type), cat_id (if the cat_type is category the cat_id corresponds to categories table, or if the cat_type is type the cat_id corresponds to the type table).

In active admin keyword_categories.rb i have

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
  end
  f.actions
end

I followed SO Questions, but i dont understand, how do i return value from the controller to the active admin rb file

I am a newbie to jquery

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...