Using rails_admin 0.6.2, I added a custom field for counting related objects. For example, in the list of blog posts, show how many comments everyone has.
config.model Post do list do field :id field :comment_count, :integer do def value bindings[:object].comment.count end filterable true end
I want to be able to filter based on this number - show me posts with 0 comments, between 1 and 10, etc.
Right now there is no way to do this, since this account has just been created with the request N + 1; every time he posts a post, he requests a comment counter. I would need to add a WHERE to his earlier request for messages.
source share