ActiveAdmin display collection in Show method

activeadmin, ruby-on-rails

Solution

It's happening because the row shows the output of this line `package.components.each {|component| ... }` and that's the collection

Try this:

show do

 attributes_table do
  row :description

  row 'Components' do |n|
     package.components.map(&:name).join("<br />").html_safe
  end
 end

end

or any other join string you prefer :)

Problem

I have Packages, which have multiple Components (linked using a has_many through Bundles) In ActiveAdmin, when I show a Package I want to be able to show all the Components linked to it So I have a show method as follows: ``` show do attributes_table do row :description row 'Components' do |n| package.components.each do |component| #debugger component.name end end end end ``` When I display the page, it shows the full version of each record, ie (one of which I show below, but there will be as many as there are Components): ``` [#<Component id: 2, component_token: "6e9be0b0-71c0-012f-d523-00254bca74c4", name: "Exercise Module", description: "This is the exercise module", created_at: "2012-04-26 11:25:20", updated_at: "2012-04-26 11:25:20">] ``` When I stop the debugger at the point I have commented it, the value for component.name is given as "Exercise Module", but that is not what is outputted to the show - in fact, ActiveAdmin seems to ignore everything in that |component| block. How do I display the record attributes, and not the whole record itself? Thanks

Original source