【发布时间】:2013-06-10 22:32:34
【问题描述】:
我正在尝试使用 will_paginate gem,但是出了点问题。我遇到了undefined method `paginate' 错误。我阅读了很多问题并尝试了很多事情。
这就是我所拥有的:
这是我的 LocationsController.rb:
def index
@locations = Location.all
respond_to do |format|
@locations = @locations.paginate(:page => params[:page], :per_page => 10)
format.html #index.html.erb
format.json { render json: @locations }
end
end
这是我的index.html.erb 中的 will_paginate 行:
<%= will_paginate @locations %>
这是错误:
undefined method `paginate' for #<Class:0xaa2e48c>
我还在 Gemfile 中添加了 require 部分:
gem "will_paginate", "~> 3.0.4", :require => nil
这是在我的environment.rb 的末尾:
require "will_paginate"`
【问题讨论】:
标签: ruby-on-rails will-paginate