ruby - Show page, show associations -
i try find out how can show associations deeper 1 level.
show @ form, done there:
form |f| f.inputs "details" f.input :name f.input :item_category f.input :resource f.input :status end f.inputs "actions" f.semantic_errors *f.object.errors.keys f.has_many :item_actions, :allow_destroy => true, :heading => 'planets', :new_record => true |obj| obj.input :action obj.input :status obj.input :_destroy, :as=>:boolean, :required => false, :label=>'remove' obj.has_many :item_action_skills, :heading => "skills" |ias| ias.input :skill ias.input :level end end end f.actions end
you can see, show has_many :item_actions , going 1 level deeper item_action.item_action_skills. on form works perfect.
now i'll want on show page too. code:
show |obj| attributes_table 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" table_for obj.item_actions column :action column(:status) {|obj| status_tag(obj.status_string.first, obj.status_string.last) } end end active_admin_comments end
i write table_for, how go next association? want item_action.item_action_skills.
i have no idea. idea?
thanks!
ruby 1.9.3 rails 3.2.14 activeadmin 0.6.0
try this:
panel "actions" table_for obj.item_actions column :action column(:status) {|obj| status_tag(obj.status_string.first, obj.status_string.last) } column("skills"){|resource| table_for resource.item_action_skills column(:your_column) end } end end
Comments
Post a Comment