0

There is a good question here explaining how to correctly use ActiveAdmin with associations.

In my situation though I have a customer model has_many associated to a sales model and the sales model is pretty big. So when I try to view my customer page in ActiveAdmin the server is running a call for all sales so that (I am guessing) it can return those associated columns.

This is timing out my server (504 Gateway Time-out ngx_openresty/1.4.3.6).

Is there any way to say to ActiveAdmin to ignore an association for that view? Ie the index view. Once I get to the 'show' view and have isolated a customer it is ok to run the query on that customers sales but running all customers with all sales is not required on the index page.

Hope I have been clear.

Community
  • 1
  • 1
Jay Killeen
  • 2,832
  • 6
  • 39
  • 66

1 Answers1

0

Ok I have just realised that without specifying which columns I want in the index on the customer.rb file it will try and grab all including the associated columns (correct me if I am wrong on that).

Either way, before I only had he config.per_page line. By adding index do and my columns it is working properly. That was easy!

ActiveAdmin.register Customer do

  config.per_page = 25

  index do
    selectable_column
    id_column
    column :customer_code
    column :customer_name
    column :customer_rep_name
    column :created_at
    actions
  end

  filter :customer_rep_name
  filter :market_segment_name

end
Jay Killeen
  • 2,832
  • 6
  • 39
  • 66