views:

36

answers:

1

Especially when you are using Searchlogic. It is kinda hard for me to guess what named scope to use to achieve what I need.

+1  A: 

You can get all defined named scopes for a model, using

Model.scopes
=> {:one_scope_name=>#<Proc:0x0000...>, :other_scope_name=>#<Proc:0x0000...>, ... }

It gives you a hash, so if you want only names, use Model.scopes.keys

But this will give you only scopes, that are already defined. It won't help you will scopes, generated by searchlogic, because, as you can read in documentation (Under the hood section), scopes like field_eq etc are created only when they are first used:

"Searchlogic utilizes method_missing to create all of these named scopes. When it hits method_missing it creates a named scope to ensure it will never hit method missing for that named scope again. Sort of a caching mechanism. It works in the same fashion as ActiveRecord’s “find_by_*” methods. This way only the named scopes you need are created and nothing more."

Voyta
Great, Thanks! glad somebody do understand
jaycode