Check if an object is an ActiveRecord scope

Posted . Visible to the public.

Don't say is_a?(ActiveRecord::NamedScope::Scope) because that is no longer true in Rails 3 and also doesn't match unscoped ActiveRecord classes themselves (which we consider scopes for all practical purposes).

A good way is to say this instead:

object.respond_to?(:scoped)
Henning Koch
Last edit
Keywords
test
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2012-08-01 11:36)