當我試圖在我的rails項目上實現分頁時,我收到了一個no方法錯誤。 undefined method 'paginate' for #<Mongoid::Criteria:0x007fb256e54588>
在我的控制,我有:
@user = User.all.paginate(:page => params[:page], :per_page => 10)
在我的index.html.erb文件我有<%= will_paginate @user %>
上面我的HTML標籤<table>
和下面的結束HTML標籤</table>
我有will_paginate和mongoid,分頁寶石安裝正確。我已經嘗試重新啓動dev服務器..我是否缺少其他東西?Rails 4 - will_paginate和mongodb
0
A
回答
0
您要使用的will_paginate_mongoid
gem:
它只是創建了will_paginate接口兼容的PAGINATE方法[...]
的mongoid-pagination
寶石需要您手動include Mongoid::Pagination
在您的模型和並沒有專門與will_paginate
寶石整合。
0
will_paginate gem支持Mongoid開箱即用。
require 'will_paginate/mongoid'
在你的控制器動作
User.all.paginate(page: params[:page], per_page: 10)
相關問題
- 1. Rails 4 + mongodb + activeadmin
- 2. Rails:黑子和Will_Paginate問題
- 3. Rails 4 - 定製will_paginate頁面2+
- 4. Rails 4 will_paginate;不更改頁面
- 5. 軌道4 - will_paginate
- 6. Rails will_paginate和ajax附加頁
- 7. Rails will_paginate persistence
- 8. MongoDB和Laravel 4
- 9. Rails 3 will_paginate錯誤
- 10. Ruby on Rails will_paginate - NoMethodError
- 11. 打印和will_paginate
- 12. rails will_paginate和頁面緩存排序
- 13. 如何在rails中使用will_paginate和ransack
- 14. Will_paginate不渲染Ruby On Rails
- 15. Ruby on Rails,will_paginate,複選框
- 16. Rails Will_paginate:包含父母嗎?
- 17. Ajaxify will_paginate在rails 3.1中
- 18. rails will_paginate with JQuery UI Tabs
- 19. 覆蓋Rails mislav-will_paginate插件
- 20. 軌道4和寶石(will_paginate)未部署正確
- 21. Rails 4和ActionCable
- 22. Flexslider和Rails 4
- 23. will_paginate和named_routes
- 24. will_paginate和facebook/facebooker
- 25. 使用MongoDB在rails中搜索4
- 26. 配置Rails 4,MongoDB,黃瓜,水豚
- 27. Rails 3.1和MongoDB - ActiveRecords?
- 28. Ruby on Rails和MongoDB
- 29. Rails 3 MySql和MongoDB
- 30. Rails和MongoDB與MongoMapper