will_paginate helper undefined in sinatra with mongoid

China☆狼群 提交于 2019-12-08 08:57:47

问题


I am using sinatra 1.4.3 and mongoid 3.1.4. I tried adding will_paginate gem from master branch for mongoid support so I added this to my gemfile:

gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', 
                     :branch => 'master'

In environment.rb I added:

require 'will_paginate'
require 'will_paginate/mongoid'

And pagination method started working. I have still problem with will_paginate helper. In my views I get errors like:

NoMethodError: undefined method `will_paginate' for #<Class:0x006ff5df8578b0>

Am I missing something for helper to work under sinatra?


回答1:


I don't know if it's best solution but adding

include WillPaginate::Sinatra::Helpers

in my controller solved my problems.



来源:https://stackoverflow.com/questions/18204543/will-paginate-helper-undefined-in-sinatra-with-mongoid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!