Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying related resources on show page displays raw objects at the end #4550

Closed
davidalejandroaguilar opened this issue Jul 27, 2016 · 2 comments

Comments

@davidalejandroaguilar
Copy link

I'm trying to display the sides for my order_item's. (Order has_many order_items has_many Sides through OrderItemSides)

I'm trying in two ways: 1) Iteration 2) Table_for (since it is a collection of related resources)

  1. For some reason, ActiveAdmin will display the raw objects at the end of the first column (i.e. #OrderItemSide:0x007fdc59a04be0).

  2. Second column works but it creates a table inside my table.

Is this even possible in ActiveAdmin? I've looked everywhere!

    panel "Order Details" do
      table_for order.order_items, sortable: true, class: "product-order-table" do
        order = Order.find(params[:id])
        order_items = order.order_items

        column "Sides" do |oi|
          oi.order_item_sides.each do |ois|
            ul do 
              li ois.side.name
            end
          end
        end

        column "Sides" do |oi|
          table_for oi.order_item_sides do
            column do |ois|
              ul do
                li ois.side.name
              end
            end
          end
        end

da2553290a408a790eb2a04bc73dbb23

@grubinsky
Copy link

column method of table_for is meant to render the result of the block it receives.
each statement return the last iterated item. That's way you are seeing that on the first example.

I notice you are rendering an ul and li for each side. So if you change that your problem goes away because ul just render html and doesn't return anything.

I meant to changing it this way:

column "Sides" do |oi|
  ul do
    oi.order_item_sides.each do |ois|
      li ois.side.name
    end
  end
end

@timoschilling
Copy link
Member

I’m going to close this since you haven’t responded. Please feel free to update this issue with additional information so it can be reconsidered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants