2016-10-04 2 views
0

나는 그렇게으로 ProspectReview에 대한 active_admin 양식이 있습니다별도의 레일즈 모델을 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 양식 (카테고리 선택 드롭 다운 메뉴) :

언제든지 테이블 main_topics은 새 행으로 업데이트됩니다. 이름 열에있는 것이 무엇 이건간에 드롭 다운 선택 안에 채워집니다.

답변

0

대답은 간단했습니다.

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

MainTopic.all에서 []을 제거해야했습니다.