Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:51:58+00:00 2026-06-14T11:51:58+00:00

When show ing a resource using the Rails ActiveAdmin gem, I want to show

  • 0

When showing a resource using the Rails ActiveAdmin gem, I want to show a table of another associated model.

So let’s say a Winery has_many :products. Now I want to show the products associated on the show page of the Winery admin resource. And I want that to be a table similar to what I would get on the index of the Products resource.

I got it to work, but only by recreating the HTML structure manually, which kind of sucks. Is there a cleaner way to create an index table style view for a specific subset of an associated resource?

What I have, which kinda sucks:

show title: :name do |winery|
  attributes_table do
    row :name
    row(:region) { |o| o.region.name }
    rows :primary_contact, :description
  end

  # This is the part that sucks.
  div class: 'panel' do
    h3 'Products'
    div class: 'attributes_table' do
      table do
        tr do
          th 'Name'
          th 'Vintage'
          th 'Varietal'
        end
        winery.products.each do |product|
          tr do
            td link_to product.name, admin_product_path(product)
            td product.vintage
            td product.varietal.name
          end
        end
      end
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:51:59+00:00Added an answer on June 14, 2026 at 11:51 am

    To solve this problem, we used partials:

    /app/admin/wineries.rb

    ActiveAdmin.register Winery do
      show title: :name do
        render "show", context: self
      end
    end
    

    app/admin/products.rb

    ActiveAdmin.register Product do
      belongs_to :winery
      index do
        render "index", context: self
      end
    end
    

    /app/views/admin/wineries/_show.builder

    context.instance_eval  do
      attributes_table do
        row :name
        row :region
        row :primary_contact
      end
      render "admin/products/index", products: winery.products, context: self
      active_admin_comments
    end
    

    /app/views/admin/products/_index.builder

    context.instance_eval  do
      table_for(invoices, :sortable => true, :class => 'index_table') do
        column :name
        column :vintage
        column :varietal
        default_actions rescue nil # test for responds_to? does not work.
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Simple Form gem in my Rails app. In my sign-up form,
while showing progress bar i want to disable touch screen to restrict other functionalities
When showing data from a mysql table on an php page does it have
My program is showing it is a leap year for every output. Please let
Select only showing first character of option text in IE 9 Using click on
I am showing place by using pin image on google map in android by
Using ASP.Net & C# I want to run my web page in the internet
I need some help with echoing an SQL field but it keeps showing Resource
I am creating an app using Ruby on Rails and in the Admin panel
I have recently created a new rails 3 application, using the code that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.