Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-475

increase paginate per_page to 30

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.0.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Currently Post.paginate(:page => 2) returns whole collection (which is confusing), but will_paginate Gem always had the default :per_page setting of 30 (also it validates the parameter to be > 1). I looked at contexts/paging.rb and not sure why it doesn't do something like this:

      diff --git a/lib/mongoid/contexts/paging.rb b/lib/mongoid/contexts/paging.rb
      index 5bfb844..9f906b1 100644
      — a/lib/mongoid/contexts/paging.rb
      +++ b/lib/mongoid/contexts/paging.rb
      @@ -13,12 +13,8 @@ module Mongoid #:nodoc:

      1. A collection of documents paginated.
      2. All previous <tt>limit</tt> and <tt>skip</tt> call will be ignored.
        def paginate(pager_options={})
      • if pager_options[:per_page]
      • options[:limit] = pager_options[:per_page].to_i
      • if pager_options[:page]
      • options[:skip] = (pager_options[:page].to_i - 1) * pager_options[:per_page].to_i
      • end
      • end
        + options[:limit] = per_page
        + options[:skip] = (page - 1) * per_page

      @collection ||= execute(true)
      WillPaginate::Collection.create(page, per_page, count) do |pager|
      @@ -43,7 +39,7 @@ module Mongoid #:nodoc:
      #

      1. The Integer number of documents in each page.
        def per_page
      • (options[:limit] || 20).to_i
        + (options[:limit] || 30).to_i
        end
        end
        end

            Assignee:
            Unassigned Unassigned
            Reporter:
            dolzenko Evgeniy Dolzhenko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: