Index: test/array_pagination_test.rb =================================================================== --- test/array_pagination_test.rb (revision 409) +++ test/array_pagination_test.rb (working copy) @@ -98,6 +98,13 @@ assert_equal nil, entries.total_entries end + def test_create_guesses_page + entries = WillPaginate::Collection.create(nil, 5) do |pager| + pager.replace array + end + assert_equal 1, entries.current_page + end + private def create(page = 2, limit = 5, total = nil, &block) WillPaginate::Collection.create(page, limit, total, &block) Index: lib/will_paginate/collection.rb =================================================================== --- lib/will_paginate/collection.rb (revision 409) +++ lib/will_paginate/collection.rb (working copy) @@ -16,7 +16,7 @@ # populating the collection using the +replace+ method. # def initialize(page, per_page, total = nil) - @current_page = page.to_i + @current_page = page ? page.to_i : 1 @per_page = per_page.to_i self.total_entries = total if total