1 レベルよりも深い関連付けを表示する方法を見つけようとしています。
私のFORMに表示してください。私はそこでやっただけです:
form do |f|
f.inputs "Details" do
f.input :name
f.input :item_category
f.input :resource
f.input :status
end
f.inputs "Actions" do
f.semantic_errors *f.object.errors.keys
f.has_many :item_actions, :allow_destroy => true, :heading => 'Planets', :new_record => true do |obj|
obj.input :action
obj.input :status
obj.input :_destroy, :as=>:boolean, :required => false, :label=>'Remove'
obj.has_many :item_action_skills, :heading => "Skills" do |ias|
ias.input :skill
ias.input :level
end
end
end
f.actions
終わり
ご覧のとおり、has_many :item_actions を示しており、item_action.item_action_skills まで 1 レベル深く進んでいます。このフォームでは完璧に機能します。
今度は番組ページにも載せたいと思います。私のコード:
show do |obj|
attributes_table do
row :name
row :item_category
row(:resource) {|obj| status_tag((obj.resource ? 'yes' : 'no'), (obj.resource ? :ok : :error))}
row(:status) {|obj| status_tag(obj.status_string.first, obj.status_string.last) }
end
panel "Actions" do
table_for obj.item_actions do
column :action
column(:status) {|obj| status_tag(obj.status_string.first, obj.status_string.last) }
end
end
active_admin_comments
終わり
table_for と書いていますが、どうやって次の関連付けに行くのでしょうか?item_action.item_action_skills が欲しいです。
何も思いつきません。何か案が?
ありがとう!
Ruby 1.9.3 Rails 3.2.14 ActiveAdmin 0.6.0