paginate
This commit is contained in:
parent
61380a5e1a
commit
45f8b15083
|
@ -625,7 +625,7 @@ class ApplicationController < ActionController::Base
|
||||||
@obj_count = obj.count
|
@obj_count = obj.count
|
||||||
@obj_pages = Paginator.new @obj_count, pre_size, params['page']
|
@obj_pages = Paginator.new @obj_count, pre_size, params['page']
|
||||||
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
|
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
|
elsif obj.kind_of? Array
|
||||||
obj[@obj_pages.offset, @obj_pages.per_page]
|
obj[@obj_pages.offset, @obj_pages.per_page]
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,8 +15,7 @@ class StoresController < ApplicationController
|
||||||
reorder("created_on DESC")
|
reorder("created_on DESC")
|
||||||
result = result.to_a
|
result = result.to_a
|
||||||
result.map { |res| result.delete(res) if res.container.nil?}
|
result.map { |res| result.delete(res) if res.container.nil?}
|
||||||
@searched_attach = result
|
@searched_attach = paginateHelper result
|
||||||
return @searched_attach
|
|
||||||
end
|
end
|
||||||
|
|
||||||
LIMIT = 12 unless const_defined?(:LIMIT)
|
LIMIT = 12 unless const_defined?(:LIMIT)
|
||||||
|
|
|
@ -24,7 +24,8 @@ module StoresHelper
|
||||||
when 'Bid'
|
when 'Bid'
|
||||||
bid_path(container)
|
bid_path(container)
|
||||||
else
|
else
|
||||||
'#'#logger.error "StoresHelper#attachUrl unkown type ==> #{container}"
|
Rails.logger.error "ERROR: StoresHelper#attachUrl unkown type ==> #{container}"
|
||||||
|
'#'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,6 +33,8 @@ module StoresHelper
|
||||||
come_from_local(attachment).join(" > ").html_safe
|
come_from_local(attachment).join(" > ").html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
WORD_LIMIT = 100
|
WORD_LIMIT = 100
|
||||||
def come_from_local attachment
|
def come_from_local attachment
|
||||||
|
|
||||||
|
@ -93,8 +96,6 @@ module StoresHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def project_link project
|
def project_link project
|
||||||
if project.nil?
|
if project.nil?
|
||||||
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil?"
|
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil?"
|
||||||
|
@ -123,7 +124,7 @@ module StoresHelper
|
||||||
when 3 # 作业
|
when 3 # 作业
|
||||||
if bid.courses.first.nil?
|
if bid.courses.first.nil?
|
||||||
Rails.logger.error "ERROR: attachment type unkown #bid_link/when 3"
|
Rails.logger.error "ERROR: attachment type unkown #bid_link/when 3"
|
||||||
return [link_to(bid.id, '#')]
|
return [link_to('unkown', '#')]
|
||||||
end
|
end
|
||||||
bid_list = link_to l(:label_homework), project_homework_path(bid.courses.first)
|
bid_list = link_to l(:label_homework), project_homework_path(bid.courses.first)
|
||||||
bid_item = link_to bid.name, respond_path(bid)
|
bid_item = link_to bid.name, respond_path(bid)
|
||||||
|
|
|
@ -35,4 +35,6 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<!-- <%= @searched_attach.to_s %> -->
|
<!-- <%= @searched_attach.to_s %> -->
|
||||||
|
|
||||||
|
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
Loading…
Reference in New Issue