2009-08-01 68 views
1

我試着下面的代碼,但它不工作如何分頁博客文章在Rails應用程序

class BlogsController < ApplicationController 
    def index 
    #@entry_pages = Paginator.new(self, Entry.count, 10, params[:page]) 
    @entries = Entry.find(:all, 
    #:limit => @entry_pages.items_per_page, 
    #:offset => @entry_pages.current.offset, 
    :order => 'entries.created_at DESC', 
    :include => :user) 
    end 
end 

這是博客的觀點

<h1>Recently updated blogs</h1> 
<% @entries.each do |entry| %> 
<p> 
<%= link_to entry.user.username, entries_url(:user_id => entry.user) %><br /> 
'<%= entry.title %>' was posted <%= time_ago_in_words(entry.created_at) %> ago 
</p> 
<% end %> 

我想要的物品要像分頁這個:

<<[1][2][3]>> 

回答

13

will_paginate創業板試試。 它提供了分類博客條目所需的所有功能。

+0

+1 will_paginate是軌道的經典插件 – 2009-08-03 16:01:48

相關問題