2012-02-01 2 views
1

에 대한 특성의 컬렉션을 나는이 모델 속성이 있습니다활성 관리자는 모델

class CreateRoles < ActiveRecord::Migration 
    # create role model with relation to users and projects 
    def change 
    create_table :roles do |t| 
     t.references :user 
     t.references :project 
     t.boolean :senior_author , :default => 0 
     t.boolean :first_author  , :default => 0 
     t.boolean :author   , :default => 0 
     t.boolean :bio_informatician, :default => 0 
    end 
    end 
end 

나의 양식은 다음과 같습니다

form do |f| 
    f.inputs "Details" do # Project's fields 
    f.input :title 
    f.input :code 
    end 

    f.has_many :roles do |app_f| 
    app_f.inputs do 
     if !app_f.object.nil? 
     app_f.input :_destroy, :as => :boolean, :label => "Effacer" 
     end 

     app_f.input :user, :include_blank => false, :label_method => :to_label 
     #app_f.input :senior_author 
     #app_f.input :first_author 
     #app_f.input :author 
     #app_f.input :bio_informatician 
    end 
    end 
    f.buttons 
end 
내가 컬렉션을 (할 수있는 방법

) 또는 라디오 버튼의 넷 마지막 app_f.input?

답변

5

이 당신을 도울 것입니다 경우 모르겠어요,하지만 난 formtastic 레코드와 선택하지 않는 매우 낯선 생각 collection 속성

f.input :user, :collection => User.all.map{|u| [u.name, u.id]} 

를 사용할 수 있습니다.

+0

이 컬렉션 유형의 맵은 저에게 적합하지 않습니다 ... activeadmin은 항상 내 u.name 대신 u.cod를 보여줍니다 ... 내 컬렉션 : User.all.map {| u | [u.cod, u.id]} – squiter

+0

@BrunnoDosSantos 귀하의 activeadmin 버전은 무엇입니까? – Duke

+0

activeadmin (1.0.0.pre) – squiter

관련 문제