使用will_paginate gem时出现paginate错误

时间:2016-06-16 09:31:57

标签: ruby-on-rails ruby pagination

我正在尝试显示所有用户并想要对它们进行分页 我添加了这两个宝石:

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.

任何帮助?

1 个答案:

答案 0 :(得分:1)

你误认为宝石,will_paginate是this,应该加上

gem 'will_paginate'

虽然您实际上已将this gem添加到上述语句中。