问题
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