【问题标题】:paginate error while using will_paginate gem使用 will_paginate gem 时出现分页错误
【发布时间】:2016-06-16 17:51:00
【问题描述】:

我正在尝试显示我的所有用户并希望对他们进行分页 我添加了这两个宝石:

gem 'paginate', '~> 4.0', '>= 4.0.1'
gem 'bootstrap-will_paginate', '~> 0.0.10'

以下行给了我一个错误:

@users = User.paginate(page: params[:page])

我试过@users = User.all.paginate(page: params[:page])@users = User.paginate :all, :page => params[:page]

错误是: You tried to define a scope named "paginate" on the model "ActiveRecord::SchemaMigration", but Active Record already defined a class method with the same name.

有什么帮助吗?

【问题讨论】:

    标签: ruby-on-rails ruby pagination


    【解决方案1】:

    你弄错了 gem,will_paginate 是this,应该加上

    gem 'will_paginate'
    

    虽然您实际上是在上面的语句中添加this gem。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-24
      • 2011-07-17
      • 1970-01-01
      相关资源
      最近更新 更多