From 63284212e5ccb024cb60ca7df11828dbd86d3588 Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 18 Jul 2014 14:32:13 +0800 Subject: [PATCH] Pagination --- app/controllers/admin/diplomas_controller.rb | 2 +- app/controllers/personal_diplomas_controller.rb | 5 +++-- app/views/admin/diplomas/index.html.erb | 10 ++++------ lib/personal_diploma/engine.rb | 1 + 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/diplomas_controller.rb b/app/controllers/admin/diplomas_controller.rb index ce6d9fa..6e4054d 100644 --- a/app/controllers/admin/diplomas_controller.rb +++ b/app/controllers/admin/diplomas_controller.rb @@ -5,7 +5,7 @@ class Admin::DiplomasController < OrbitMemberController before_action :get_settings,:only => [:new, :edit, :setting] def index - @diplomas = Diploma.all + @diplomas = Diploma.order_by(:end_date=>'desc',:start_date=>'desc').page(params[:page]).per(10) end def new diff --git a/app/controllers/personal_diplomas_controller.rb b/app/controllers/personal_diplomas_controller.rb index 8d9d337..6dd8557 100644 --- a/app/controllers/personal_diplomas_controller.rb +++ b/app/controllers/personal_diplomas_controller.rb @@ -1,6 +1,6 @@ class PersonalDiplomasController < ApplicationController def index - diplomas = Diploma.where(:is_hidden=>false).all + diplomas = Diploma.where(:is_hidden=>false).order_by(:end_date=>'desc', :start_date=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) diploma_list = diplomas.collect do |diploma| { "member" => diploma.member_profile.name, @@ -19,7 +19,8 @@ class PersonalDiplomasController < ApplicationController "th_school_name" => t('personal_diploma.school_name'), "th_degree" => t('personal_diploma.degree'), "th_detail" => t('detail') - } + }, + "total_pages" => diplomas.total_pages } end diff --git a/app/views/admin/diplomas/index.html.erb b/app/views/admin/diplomas/index.html.erb index 4efdf5d..a365c30 100644 --- a/app/views/admin/diplomas/index.html.erb +++ b/app/views/admin/diplomas/index.html.erb @@ -8,14 +8,12 @@ - <%= render :partial => 'diploma', :collection => @diplomas %> + <%= render 'diploma' %> - \ No newline at end of file + \ No newline at end of file diff --git a/lib/personal_diploma/engine.rb b/lib/personal_diploma/engine.rb index c922191..af68243 100644 --- a/lib/personal_diploma/engine.rb +++ b/lib/personal_diploma/engine.rb @@ -14,6 +14,7 @@ module PersonalDiploma frontend_enabled icon_class_no_sidebar "icons-user" + data_count 1..10 end end end