Skip to content

Fetch per_page from model by default #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

JiriChara
Copy link
Contributor

Both kaminari and will_paginate support per_page configuration on the model:

# kaminari
class User < ActiveRecord::Base
  paginates_per 50
end
# will_paginate
class User < ActiveRecord::Base
  self.per_page = 50
end

This PR is adding a functionality to api-pagination to use the values from model by default, so the per_page doesn't have to be same for all resources or overridden in controller.

def index
  @users = User.all
  paginate @users # per_page will be 50
end

Fixes #48

davidcelis added a commit that referenced this pull request Feb 24, 2016
@davidcelis davidcelis merged commit 7674b1b into davidcelis:master Feb 24, 2016
@davidcelis
Copy link
Owner

💖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants