Pagination

This commit is contained in:
manson 2014-07-18 15:03:24 +08:00
parent ec6173efe3
commit d441bf2135
4 changed files with 7 additions and 4 deletions

View File

@ -5,7 +5,7 @@ class Admin::HonorsController < OrbitMemberController
before_action :get_settings,:only => [:new, :edit, :setting]
def index
@honors = Honor.all
@honors = Honor.order_by(:year=>'desc').page(params[:page]).per(10)
end
def new

View File

@ -1,6 +1,6 @@
class PersonalHonorsController < ApplicationController
def index
honors = Honor.where(:is_hidden=>false).all
honors = Honor.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
honor_list = honors.collect do |honor|
{
"year" => honor.year,
@ -19,7 +19,8 @@ class PersonalHonorsController < ApplicationController
"th_awarding_unit" => t('personal_honor.awarding_unit'),
"th_award_winner" => t('personal_honor.award_winner'),
"th_detail" => t('detail')
}
},
"total_pages" => honors.total_pages
}
end

View File

@ -8,7 +8,7 @@
</tr>
</thead>
<tbody id="tbody_experiences" class="sort-holder">
<%= render :partial => 'honor', :collection => @honors %>
<%= render 'honor' %>
</tbody>
</table>
@ -17,5 +17,6 @@
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_honor_setting_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@honors), class: "pagination pagination-centered" %>
</div>
</div>

View File

@ -14,6 +14,7 @@ module PersonalHonor
frontend_enabled
icon_class_no_sidebar "icons-user"
data_count 1..10
end
end
end