在sinatra中使用monongoid定义的will_paginate helper [英] will_paginate helper undefined in sinatra with mongoid

查看:69
本文介绍了在sinatra中使用monongoid定义的will_paginate helper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用sinatra 1.4.3和mongoid 3.1.4.我尝试从master分支添加will_paginate gem以获得mongoid支持,因此将其添加到我的gemfile中:

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'

在environment.rb中,我添加了:

In environment.rb I added:

require 'will_paginate'
require 'will_paginate/mongoid'

分页方法开始起作用.我对will_paginate助手仍然有疑问.在我看来,我会收到类似以下错误:

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>

我是否缺少帮助者在sinatra下工作的东西?

Am I missing something for helper to work under sinatra?

推荐答案

我不知道这是否是最好的解决方案,但要添加

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

include WillPaginate::Sinatra::Helpers

在我的控制器中解决了我的问题.

in my controller solved my problems.

这篇关于在sinatra中使用monongoid定义的will_paginate helper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆