2016-10-04 16 views
0

我有一個active_admin形式ProspectReview像這樣:如何將單獨的導軌模型添加到active_admin表單中?

create_table "main_topics", force: :cascade do |t| 
    t.string "name", limit: 255 
    t.datetime "created_at", null: false 
    t.datetime "updated_at", null: false 
end 

我的目標是從main_topics添加屬性名稱:

與名稱的屬性
ActiveAdmin.register ProspectReview do 

    permit_params :domain, :media_type, :is_prospect, :category, :corrected_domain, :source, :share, :collection, :api_lookup_at 

    form do |f| 
    f.inputs "ProspectReview" do 
     f.input :domain 
     f.input :media_type, :as => :select, :collection => ["website","facebook","twitter","blogspot","tumblr","instagram","klout","pinterest","google+","linkedin","youtube","blog","mobile app","lookbook","bloglovin"] 
     f.input :is_prospect, :as => :select, :collection => ["yes", "no"] 
     f.input :category, :as => :select, :collection => [] 
     f.input :corrected_domain 
     f.input :source 
     f.input :share 
    end 
    f.actions 
    end 

end 

我有一個表稱爲main_topics進入ProspectReview ActivAdmin表格,其中類別選擇下拉列表爲:

f.input :category, :as => :select, :collection => [] 

這樣,無論何時表main_topics用新行更新。無論名稱列中的內容都會填充到下拉列表中。

回答

0

答案很簡單。我得到一個錯誤

f.input :category, :as => :select, :collection => [MainTopic.all] 

我需要刪除MainTopic.all周圍的[]。

相關問題