Commit 8178a3cd by ivan Lan

Improve new paginate about total_page

parent 9345fce4
...@@ -150,7 +150,12 @@ module Shotengai ...@@ -150,7 +150,12 @@ module Shotengai
end end
def paginate resources, page: , per_page: def paginate resources, page: , per_page:
return resources if skip_paginate?(page, per_page) if skip_paginate?(page, per_page)
@total_page = 1
return resources
end
@total_page = (resources.count / per_page) + 1
# page start with 1 # page start with 1
if resources.is_a?(Array) if resources.is_a?(Array)
resources[(page - 1) * per_page ... page * per_page] || [] resources[(page - 1) * per_page ... page * per_page] || []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment