【发布时间】:2013-04-01 14:13:10
【问题描述】:
我无法使用 will_paginate 呈现我的项目。我收到此错误
undefined method `total_pages' for #<Enumerator:0x007fe098856378>
这是我在控制器上的分页
@com = @text.comments.sorted.paginate(:page => 1, :per_page => 30)
还有我的查看文件代码。
<% will_paginate @com.each do |text| %>
<div class="comments"> <p class="time"><%= Time.now %></p>
<p><%= text.text %></p></div>
而控制器文件是
def show
@text = Microblog.find(params[:id])
@com = @text.comments.sorted.paginate(:page => 1, :per_page => 2)
@rating = (@text.up - @text.down)
end
还有模型文件
class Comment < ActiveRecord::Base
attr_accessible :text, :microblog_id
belongs_to :microblog
scope :sorted, order("comments.created_at DESC")
end
我找不到这里有什么问题:(
【问题讨论】:
-
你能把错误贴出来
-
我已经在第一行发布了错误。这是#<0x007fe098856378>0x007fe098856378>
标签: ruby-on-rails will-paginate