Open Roguelazer opened 1 year ago
Hey @Roguelazer, the search
method needs to be called on the model, not a relation. You can use the model
method to get it from the relation.
Unfortunately, that doesn't quite work; the model
appears to still have a current_scope
if it's called from within a scope.
Describe the bug I have an application using Rails 6 and Rails-Admin. Upgrading searchkick to 5.x makes all rails_admin pages fail with "search must be called on model, not relation" (because rails_admin always uses a scope). However, even if I exit the scope by calling
unscoped
, this failure still occurs. I believe that in addition to checking forcurrent_scope.nil?
, searchkick should also check forcurrent_scope == {}
To reproduce Use this code to reproduce when possible:
Additional context
Changing
relation?
to the following definition make unscoped work: