I am using ActiveRecord with Rails 3.
I defined scopes in my model. How can I get the list of all scopes of that model?
Previously I could use Model.scopes
OR
Can I check a scope is defined or not? Something like Model.scope_defined?("scope_name")
Thanks in advance.
You can see if a scope is defined or not this way
it will return
trueif it does exist andnilif it does not.If you check the source code of
valid_scope_name?, you see that you can just test it usingrespond_to?and then avoid the logging part.