Created
May 5, 2016 13:04
-
-
Save amitpatelx/4994cbcca948f5a7e39b8b6d83d0e2a8 to your computer and use it in GitHub Desktop.
Common Pagination inside ApplicationController - With Kaminari
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def paginated(resources, per_page = 10) | |
resources.page(params[:page]).per(per_paget) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search | |
if search_case.blank? || search_case == "All" | |
@documents = paginated(current_client.documents.includes(:projects)) | |
else | |
@documents = paginated(Kaminari.paginate_array(selected_documents) # selected_documents is array | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment