Reputation: 7160
For example I have two models:
I need column in index view where I can see Posts count of each user:
index do
column :id
column :name
column :created_at
column "Posts count", :sortable => "posts.count" do |user|
user.posts.count.to_s
end
default_actions
end
My problem is :sortable => "posts.count" does not work, I received exception.
Upvotes: 2
Views: 952
Reputation: 548
Find 4.1.2.4 paragraph on the rails guides. It's about counter_cache
. I think that will help you. Just add in ActiveAdmin column :posts_count
Upvotes: 3