Module WillPaginate::NamedScope
In: lib/will_paginate/named_scope.rb
ArgumentError InvalidPage Array Collection LinkRenderer Scope ViewHelpers Finder Finder::ClassMethods lib/will_paginate/collection.rb lib/will_paginate/view_helpers.rb ViewHelpers ClassMethods Finder VERSION Deprecation lib/will_paginate/named_scope.rb ClassMethods NamedScope WillPaginate dot/m_8_0.png

This is a feature backported from Rails 2.1 because of its usefullness not only with will_paginate, but in other aspects when managing complex conditions that you want to be reusable.

Methods

included  

Classes and Modules

Module WillPaginate::NamedScope::ClassMethods

Public Class methods

All subclasses of ActiveRecord::Base have two named_scopes:

  • all, which is similar to a find(:all) query, and
  • scoped, which allows for the creation of anonymous scopes, on the fly:

    Shirt.scoped(:conditions => {:color => ‘red’}).scoped(:include => :washing_instructions)

These anonymous scopes tend to be useful when procedurally generating complex queries, where passing intermediate values (scopes) around as first-class objects is convenient.

[Source]

    # File lib/will_paginate/named_scope.rb, line 15
15:     def self.included(base)
16:       base.class_eval do
17:         extend ClassMethods
18:         named_scope :all
19:         named_scope :scoped, lambda { |scope| scope }
20:       end
21:     end

[Validate]