1

Trying to build this with Active admin 3.0. This seems so basic to me that I feel I must be missing something.

Let's assume I have a Store model and an Employee model and a store has many employees and employees belong to a store.

When I go to the show page for a store, I would like, below the main section of store attributes, to have a table that lists all the employees for that store. I would literally just like to render the employees index as a partial or something like that and that pass it the employees for that specific store.

I don't want to custom code all of this and end up having to rewrite all the index logic and related styling and html, it seems like there should be a simpler way. Is there some one liner I can throw in?

1 Answer 1

1

I hope this will help you)

ActiveAdmin.register Store do

  # other code...

  show do
    attributes_table do
      row :id
      row :name
      row :description
      # other rows for Store model...
    end

    panel 'Employees' do
      paginated_collection(store.employees.page(params[:page]).per(15), download_links: false) do
        table_for(collection, sortable: false) do
          column :id
          column :username
          # Other columns for the Employees table
        end
      end
    end
  end

  # other code...

end

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.