#< Array:0xc347540>的未定义方法页面kaminari“页面"错误. rails_admin [英] undefined method page for #<Array:0xc347540> kaminari "page" error. rails_admin

查看:68
本文介绍了#< Array:0xc347540>的未定义方法页面kaminari“页面"错误. rails_admin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用rails_admin.当我去某些资源.通过键入网址

i am using rails_admin. when i go to certain resource. by typin url

localhost:3000/admin/rule 

比它给我这个错误.代码是:

than it give me this error. code is:

scope = Rule.all
scope.page(1).per(2)

.上面的代码写在rails_admin gem.中,放在名为adapters的文件夹中的名为mongoid.rb的文件中.完整的日志是:

. above code is writtten in rails_admin gem.in a file named mongoid.rb placed in adaptors folder. complete log is:

NoMethodError (undefined method `page' for #<Array:0xcea7408>):
mongoid (2.4.8) lib/mongoid/criteria.rb:385:in  `method_missing'
/home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/kaminari-809105ad782a/lib/kaminari/models/mongoid_extension.rb:11:in `page'
/home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/rails_admin-069819944cc9/lib/rails_admin/adapters/mongoid.rb:37:in `all'
/home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/rails_admin-069819944cc9/app/controllers/rails_admin/main_controller.rb:127:in `get_collection'
/home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/rails_admin-069819944cc9/app/controllers/rails_admin/main_controller.rb:39:in `list_entries'
/home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/rails_admin-069819944cc9/lib/rails_admin/config/actions/index.rb:30:in `block (2 levels) in <class:Index>'

我应该怎么做才能解决此错误?

what should i do to resolve this error?

推荐答案

我一直在使用Mongoid反复讨论此问题.有时在RailsAdmin中刷新页面可以解决该问题.

I've been running into this issue off and on for a while now using Mongoid. Sometimes refreshing the page in RailsAdmin would fix it.

我发现问题是Kaminari的钩子没有在我的环境中初始化,因此依赖Kaminari扩展方法的模型无法使用它们.

I figured out that the problem is Kaminari's hooks are not initialized in my environment, so the models that rely on Kaminari's extension methods don't have them available.

我只是从 Kaminari的railtie ,然后将其放在我的 rails_admin初始化程序的顶部:

I simply took the following line from Kaminari's railtie and put it at the top of my rails_admin initializer:

Kaminari::Hooks.init

现在一切似乎都对我有用.但是,我不知道为什么ActiveSupport回调未运行该代码.

Now things seem to be working for me. However, I don't know why the ActiveSupport callback is not running that code.

这篇关于#&lt; Array:0xc347540&gt;的未定义方法页面kaminari“页面"错误. rails_admin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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