Pagination

This commit is contained in:
manson 2014-07-18 15:04:34 +08:00
parent 27eb2857d0
commit 53465b9831
4 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -7,11 +7,12 @@
</tr>
</thead>
<tbody id="tbody_labs" class="sort-holder">
<%= render :partial => 'lab', :collection => @labs %>
<%= render 'lab' %>
</tbody>
</table>
<div class="bottomnav clearfix">
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@labs), class: "pagination pagination-centered" %>
</div>
</div>

View File

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