Fix gallery index pagination bug.
This commit is contained in:
parent
2f01d2a5d4
commit
b242499e45
|
@ -56,7 +56,10 @@ class GalleriesController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
albums_with_order = []
|
albums_with_order = []
|
||||||
start_index = (page_data_count - (with_order_count % page_data_count) + page_data_count*(page_no - 1 - with_order_total_pages))
|
start_index = page_data_count*(page_no - 1 - with_order_total_pages)
|
||||||
|
if with_order_count != 0
|
||||||
|
start_index += (page_data_count - (with_order_count % page_data_count))
|
||||||
|
end
|
||||||
albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[start_index...(start_index+page_data_count)].to_a
|
albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[start_index...(start_index+page_data_count)].to_a
|
||||||
end
|
end
|
||||||
albums = albums_with_order.concat(albums_no_order)
|
albums = albums_with_order.concat(albums_no_order)
|
||||||
|
|
Loading…
Reference in New Issue