2011-06-16 72 views
1

我有一个集合说118个记录。将分页颠倒顺序

我使用下列对象:@tweets = @all_tweets.paginate(:page => page.to_i, :per_page => 100)进行分页我的鸣叫

1有100条记录,第2页有18

说我命令我的记录DESC秩序,我想颠倒观点。如何让页面1显示18条记录,并且页面2显示100条(最大)。

+0

所以你要显示的数量有限记录在第一页上? – 2011-06-16 21:00:05

+0

是的。我想要颠倒订单。第一页18页(最后18页),第二页100页。这是一个简单的数据库查询,但在will_paginatate中执行此操作是另一个问题。拨打分页后呼叫.reverse – 2011-06-17 00:33:06

+0

? – 2011-06-17 03:21:54

回答

0

检查http://www.wenda120.com/categories/24,这是你想要的吗?

如果是这样,开view_helpers.rb,发现to_html方法, 我这个样子的:

def to_html 
    links = @options[:page_links] ? windowed_links : [] 
    # previous/next buttons 
    links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label]) 
    links.push page_link_or_span(@collection.next_page,  'disabled next_page', @options[:next_label]) 
    html = links.join(@options[:separator]) 
    @options[:container] ? @template.content_tag(:div, html, html_attributes) : html 
end 

我改成了这样:

def to_html 
    links = @options[:page_links] ? windowed_links.reverse : [] 
    # previous/next buttons 
    links.unshift page_link_or_span(@collection.next_page,  'disabled next_page', @options[:previous_label]) 
    links.push page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:next_label]) 
    html = links.join(@options[:separator]) 
    @options[:container] ? @template.content_tag(:div, html, html_attributes) : html 
end