如何正确安装Kaminari?
我在如何让 Kaminari 工作上遇到了一些问题。我在GitHub上完成了安装过程。
gem "kaminari"
然后运行
bundle
我有这个索引片段
@users = User.order("name")
我在我的视图中添加了这个
<%= paginate @users %>
然后我得到了这个错误。
undefined method `paginate' for #<#<Class:0x00000102934330>:0x00000102932508>
我错过了什么吗?我还尝试包含页面方法
@users = User.order("id").page(1)
但我收到此错误
undefined method `page' for #<ActiveRecord::Relation:0x000001017d0300>
I'm having a bit problem on how to get Kaminari work. I did the installation procedure in GitHub.
gem "kaminari"
Then run
bundle
I have this snippet for index
@users = User.order("name")
I added this on my view
<%= paginate @users %>
Then I got this error.
undefined method `paginate' for #<#<Class:0x00000102934330>:0x00000102932508>
Did I missed something? I also tried to include the page method
@users = User.order("id").page(1)
But I get this error instead
undefined method `page' for #<ActiveRecord::Relation:0x000001017d0300>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看 kaminari 的railscast
真的很好
http://railscasts.com/episodes/254-pagination-with-kaminari
bash< /强>
Rails g kaminari:views 默认
products_controller.rb
products/index.html.erb
app/views/kaminari/_prev_span.html.erb
take a look at the railscast for kaminari
its really nice
http://railscasts.com/episodes/254-pagination-with-kaminari
bash
rails g kaminari:views default
products_controller.rb
products/index.html.erb
app/views/kaminari/_prev_span.html.erb
在项目 Gemfile 中包含 kaminari 和 bootstrap-kaminari-views gem,
在终端中执行捆绑安装,
在 products_controller.rb 中,
在 products/index.html.erb,<%= 分页@products, :theme => 'twitter-bootstrap-3' %>;
include kaminari and bootstrap-kaminari-views gems in your project Gemfile,
Execute bundle install in terminal,
In products_controller.rb,
In products/index.html.erb,<%= paginate @products, :theme => 'twitter-bootstrap-3' %>