简体   繁体   English

使用will_paginate gem时出现分页错误

[英]paginate error while using will_paginate gem

I am trying to display all my users and want to paginate them I added these two gems : 我试图显示我所有的用户,并希望对他们进行分页,所以我添加了以下两个宝石:

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

The following line gives me an error : 以下行给我一个错误:

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

I have tried @users = User.all.paginate(page: params[:page]) and @users = User.paginate :all, :page => params[:page] 我尝试过@users = User.all.paginate(page: params[:page])@users = User.paginate :all, :page => params[:page]

The error is : 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. 错误是: 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.

any help ? 有什么帮助吗?

You're mistaking gems, will_paginate is this and should be added with 您误会了宝石,will_paginate是这个 ,应该与

gem 'will_paginate'

while you're actually adding this gem with your above statement . 当您实际上在上述声明中添加 gem时。

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

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