From 45f8b15083b61011144c00c95245a169c9772480 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 15 Jan 2014 14:28:36 +0800 Subject: [PATCH] paginate --- app/controllers/application_controller.rb | 2 +- app/controllers/stores_controller.rb | 3 +-- app/helpers/stores_helper.rb | 9 +++++---- app/views/stores/search.html.erb | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2c220c25b..51b7fa804 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -625,7 +625,7 @@ class ApplicationController < ActionController::Base @obj_count = obj.count @obj_pages = Paginator.new @obj_count, pre_size, params['page'] if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation - obj.limit(@obj_pages.per_page).offset(@obj_pages.offset).all + obj.limit(@obj_pages.per_page).offset(@obj_pages.offset) elsif obj.kind_of? Array obj[@obj_pages.offset, @obj_pages.per_page] else diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index ea4812809..0fe44058e 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -15,8 +15,7 @@ class StoresController < ApplicationController reorder("created_on DESC") result = result.to_a result.map { |res| result.delete(res) if res.container.nil?} - @searched_attach = result - return @searched_attach + @searched_attach = paginateHelper result end LIMIT = 12 unless const_defined?(:LIMIT) diff --git a/app/helpers/stores_helper.rb b/app/helpers/stores_helper.rb index 3ab574e86..26f1c7630 100644 --- a/app/helpers/stores_helper.rb +++ b/app/helpers/stores_helper.rb @@ -24,7 +24,8 @@ module StoresHelper when 'Bid' bid_path(container) else - '#'#logger.error "StoresHelper#attachUrl unkown type ==> #{container}" + Rails.logger.error "ERROR: StoresHelper#attachUrl unkown type ==> #{container}" + '#' end end @@ -32,6 +33,8 @@ module StoresHelper come_from_local(attachment).join(" > ").html_safe end + private + WORD_LIMIT = 100 def come_from_local attachment @@ -93,8 +96,6 @@ module StoresHelper end end - private - def project_link project if project.nil? Rails.logger.error "ERROR: attachment type unkown #project_link project.nil?" @@ -123,7 +124,7 @@ module StoresHelper when 3 # 作业 if bid.courses.first.nil? Rails.logger.error "ERROR: attachment type unkown #bid_link/when 3" - return [link_to(bid.id, '#')] + return [link_to('unkown', '#')] end bid_list = link_to l(:label_homework), project_homework_path(bid.courses.first) bid_item = link_to bid.name, respond_path(bid) diff --git a/app/views/stores/search.html.erb b/app/views/stores/search.html.erb index 03bbf9b13..13aefcbee 100644 --- a/app/views/stores/search.html.erb +++ b/app/views/stores/search.html.erb @@ -35,4 +35,6 @@ <% end %> - \ No newline at end of file + + + \ No newline at end of file