简体   繁体   English

未定义的方法“分页”

[英]undefined method 'paginate'

I am trying to use will_paginate gem but getting this error in title.我正在尝试使用 will_paginate gem,但在标题中出现此错误。 I checked the thread below and did the changes but no luck我检查了下面的线程并进行了更改但没有运气

http://stackoverflow.com/questions/17105715/undefined-method-paginate

This is what i have这就是我所拥有的

App/Controllers/books_controller.rb应用程序/控制器/books_controller.rb

class BooksController < ApplicationController
    def index
    #@books = Book.all
    @books = Book.paginate :page => params[:page], :per_page => 10
    end
end

index.html.erb: index.html.erb:

<%= will_paginate @books %>

GemFile宝石档案

gem 'will_paginate', '~> 3.0.4'

Enbironment.rb环境文件

gem 'will_paginate'

and this is the error i get:这是我得到的错误:

undefined method `paginate' for #<Class:0x007fd539118a30>

安装 gem 后重新启动服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM