diff --git a/kaminari-core/lib/kaminari/models/page_scope_methods.rb b/kaminari-core/lib/kaminari/models/page_scope_methods.rb index d5ac025..b5deadb 100644 --- a/kaminari-core/lib/kaminari/models/page_scope_methods.rb +++ b/kaminari-core/lib/kaminari/models/page_scope_methods.rb @@ -75,7 +75,7 @@ module Kaminari # First page of the collection? def first_page? - current_page == 1 + !out_of_range? && (current_page == 1) end # Last page of the collection? diff --git a/kaminari-core/test/models/active_record/scopes_test.rb b/kaminari-core/test/models/active_record/scopes_test.rb index d852844..585227b 100644 --- a/kaminari-core/test/models/active_record/scopes_test.rb +++ b/kaminari-core/test/models/active_record/scopes_test.rb @@ -340,6 +340,12 @@ if defined? ActiveRecord test 'not on first page' do assert_false model_class.page(5).per(10).first_page? end + + test 'on first page with no record' do + model_class.delete_all + + assert_false model_class.page(1).first_page? + end end sub_test_case '#last_page?' do