Pagination

This commit is contained in:
manson 2014-07-18 15:05:27 +08:00
parent b5aa87fc7e
commit 0a087e1df4
4 changed files with 7 additions and 4 deletions

View File

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

View File

@ -1,6 +1,6 @@
class PersonalPatentsController < ApplicationController
def index
patents = Patent.where(:is_hidden=>false).all
patents = Patent.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
patent_list = patents.collect do |patent|
{
"publication_date" => patent.publish_date,
@ -20,7 +20,8 @@ class PersonalPatentsController < ApplicationController
"th_patent_no" => t('personal_patent.patent_no'),
"th_patent_country" => t("personal_patent.patent_country"),
"th_authors" => t('users.name')
}
},
"total_pages" => patents.total_pages
}
end

View File

@ -9,7 +9,7 @@
</tr>
</thead>
<tbody id="tbody_patents" class="sort-holder">
<%= render :partial => 'patent', :collection => @patents %>
<%= render 'patent' %>
</tbody>
</table>
@ -18,5 +18,6 @@
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_patent_setting_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@patents), class: "pagination pagination-centered" %>
</div>
</div>

View File

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