How can I get a list of all scopes in an ActiveRecord model using Rails 3.1?
According the documentation for 3.0.9 there is supposed to be a method called “scopes” http://api.rubyonrails.org/classes/ActiveRecord/NamedScope/ClassMethods.html#method-i-scopes, but that method doesn’t seem to exist.
You can use
Model.send(:valid_scope_name?, scope_name)to test if the scope exists in that class. Scopes did make sense in Rails 2.x but no longer in 3.x, where you have relation objects.So instead:
You would have: