Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Paginate a basic array

#74

From http://www.devchix.com/2007/07/2...

class Array
  def paginate(page=1, per_page=15)
    pagination_array = WillPaginate::Collection.new(page, per_page, self.size)
    start_index = pagination_array.offset
    end_index = start_index + (per_page - 1)
    array_to_concat = self[start_index..end_index]
    array_to_concat.nil? ? [] : pagination_array.concat(array_to_concat)
  end
end

Tests are in rSpec, will have to convert them...

Reported by Chris Wanstrath · August 4th, 2007 @ 05:33 AM

State: resolved
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Chris Wanstrath
    Chris Wanstrath
    • State changed from open to resolved

    (from [320]) will_paginate: Add #paginate method to Array [Desi McAdam] [#74 state:resolved]

    http://plugins.require.errtheblo...

    August 4th, 2007 @ 05:33 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.