diff --git a/app/controllers/admin/labs_controller.rb b/app/controllers/admin/labs_controller.rb index f01151f..53ff63d 100644 --- a/app/controllers/admin/labs_controller.rb +++ b/app/controllers/admin/labs_controller.rb @@ -5,7 +5,7 @@ class Admin::LabsController < OrbitMemberController before_action :get_settings,:only => [:new, :edit, :setting] def index - @labs = Lab.all + @labs = Lab.order_by(:year=>'desc').page(params[:page]).per(10) end def new diff --git a/app/controllers/personal_labs_controller.rb b/app/controllers/personal_labs_controller.rb index be3597e..c2dfc15 100644 --- a/app/controllers/personal_labs_controller.rb +++ b/app/controllers/personal_labs_controller.rb @@ -1,6 +1,6 @@ class PersonalLabsController < ApplicationController def index - labs = Lab.where(:is_hidden=>false).all + labs = Lab.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) lab_list = labs.collect do |lab| { "year" => lab.year, @@ -19,7 +19,8 @@ class PersonalLabsController < ApplicationController "th_location" => t('personal_lab.location'), "th_member" => t('users.name'), "th_detail" => t('detail') - } + }, + "total_pages" => labs.total_pages } end diff --git a/app/views/admin/labs/index.html.erb b/app/views/admin/labs/index.html.erb index 95227ec..71ebcc5 100644 --- a/app/views/admin/labs/index.html.erb +++ b/app/views/admin/labs/index.html.erb @@ -7,11 +7,12 @@
- <%= render :partial => 'lab', :collection => @labs %> + <%= render 'lab' %>