activeadmin: undefined method `users_user_id_eq' for Ransack::Search>:Ransack::Search

Error: undefined method `users_user_id_eq’ for Ransack::Search<class: Detail, base: Grouping <combinator: and>>:Ransack::Search

Rails 4, Ruby 2. Latest version of Active Admin.

Added basic admin functionality to a model I have called Detail. Not sure what is going on or what info might be needed to troubleshoot the bug.

Thanks for any help.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 67 (32 by maintainers)

Most upvoted comments

Ah, yeah we aren’t correctly handling nested has_many :through relationships. For now, you can just remove that filter:

ActiveAdmin.register Detail do
  remove_filter :users
end

It looks like my assumption of being able to just chain association names together was flat out wrong, but now it’s clear to me why. They work on a single has_many :through because the foreign key we are search on is an actual attribute of the direct association. So, just like we can search by :association_name_eq, we can search by :association_other_foreign_key_eq. So simple.

I’m good with switching back to the old concatenation method if you want. The chain method works nicely, but it might seem a bit too much like magic to someone down the road.

Can you run this and report on the results?

ActiveAdmin.application.namespaces[:admin].resources[:Detail].filters