diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 682511f..271c0ff 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -55,6 +55,7 @@ class GalleriesController < ApplicationController albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[0...(page_data_count - albums_with_order.count)] end else + albums_with_order = [] start_index = (page_data_count - (with_order_count % page_data_count) + page_data_count*(page_no - 1 - with_order_total_pages)) 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 @@ -132,6 +133,7 @@ class GalleriesController < ApplicationController page_no = (params[:page_no] || 1).to_i if page_no < with_order_total_pages albums_no_order = [] + albums_with_order = albums_with_order[(page_no-1)*page_data_count...page_no*page_data_count] elsif page_no == with_order_total_pages if albums_with_order.count == page_data_count albums_no_order = [] @@ -139,6 +141,7 @@ class GalleriesController < ApplicationController albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[0...(page_data_count - albums_with_order.count)] end else + albums_with_order = [] start_index = (page_data_count - (with_order_count % page_data_count) + page_data_count*(page_no - 1 - with_order_total_pages)) 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