We have a list view for a model Ticket
in rails admin that loads very slowly.
class Ticket < ActiveRecord::Base
belongs_to :crew
end
The reason it is slow is that we display the ticket's crew
relation through a method rails_admin_pretty_print
which accesses other related models.
class Crew < ActiveRecordBase
belongs_to :pool
belongs_to :leader
def rails_admin_pretty_print
"leader : #{leader.name} at time #{pool.datetime}"
end
end
I want to eager load all of these objects in the initial query in order to speed up the request. Something like:
config.model "Ticket" do
object_label_method :rails_admin_pretty_print
list do
field :crew, includes(:pool, :leader)
end
end
I can't find any way to do this in the rails admin docs. Is there a way of doing this?