Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope: Search conflicting with Ransack/Active Admin in Rails 4.1.1 #62

Closed
michaelschmitz opened this issue Jun 5, 2014 · 5 comments
Closed

Comments

@michaelschmitz
Copy link

Hi,
thanks for the work on the gem.

After updating to Rails 4.1.1, I get the following error:

c:/Ruby2/lib/ruby/gems/2.0.0/gems/activerecord-   4.1.1/lib/active_record/scoping/named.rb:143:in `scope': You tried to define a scope  named "search" on the model "ActsAsMessageable::Message", but Active Record already defined a class method with the same name. (ArgumentError)

This is due to me having installed Active Admin, which requires Ransack. Ransack also defines :search as an alias to :ransack (see here: activerecord-hackery/ransack#369). I've taken efforts to change all of my own :search scopes, but now I have to find a way to either change ransack's or messageable's scope to avoid this error.

My understanding of how to do this is currently limited, the advice in the link above regarding "remove_class" only leads to other, cascading problems. Is it possible to change the name of the scope or to have an initializer setting that renames the method?

I assume quite a few people use the "search" scope, I don't require it.

@CV-Gate
Copy link

CV-Gate commented Jan 4, 2015

+1

@LTe
Copy link
Owner

LTe commented Jan 10, 2015

I think name of search scope should be configurable. I'm open for pull requests.

@danielpclark
Copy link

+1

@Envek
Copy link

Envek commented Jun 22, 2015

Thinking Sphinx is adding search scope to models too.

Solution from #73 by @danielpclark helps. Thanks!

@LTe
Copy link
Owner

LTe commented Apr 19, 2020

Closed by #96

@LTe LTe closed this as completed Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants