amatsuda/kaminari — Issue #203: DataMapper: default_per_page just returns default value
Author: Ragmaanir
Created: 2012-02-06 18:21:09+00:00
State: open

Hi,

when i updated from Kaminari 0.12.4 to 0.13.0 some specs failed. The specs used paginates_per to change the default
value for page size to make sure that pagination links are displayed. The pagination links did not show up because it seems like the new default_per_page value set via Model.paginates_per is not used. Instead the Kaminari default value (25?) is used and since there were less than 25 records in my DB no pagination links were rendered.

This also can be tested in the rails console:

User.all.count #=> 10 # ok
User.page(1).length #=> 10 # ok
User.paginates_per 5
User.page(1).length #=> 5 # still ok
User.all.page(1).length #=> 10 # error

When i add

def default_per_page
model.default_per_page
end

to Kaminari::DataMapperCollectionMethods it seems to work again.

So in my rails-app i created an initializer as quick fix:

class DataMapper::Collection
def default_per_page
model.default_per_page
end
end

This makes sure that the value set via paginates_per is used.