Rails Active Admin 资源问题
我最近观看了关于主动管理的railscast 284,并想将其实现到我的网络应用程序中,但是当我添加资源时遇到了问题。每次尝试导航到创建的选项卡时,我都会收到以下消息:
NameError in Admin::LoadsController#index
undefined local variable or method `per' for []:ActiveRecord::Relation
Rails.root: /Users/thomascioppettini/rails_projects/want-freight
Application Trace | Framework Trace | Full Trace
Request
Parameters:
{"order"=>"id_desc"}
Show session dump
Show env dump
Response
Headers:
无
我能想到的唯一可能影响应用程序的事情是添加一个验证码来设计,这是活动管理所依赖的。
I recently have watched railscast 284 about active admin and wanted to implement it into my web app, however I am running into an issue when I add a resource. I get the following message every time I try to navigate to the created tab:
NameError in Admin::LoadsController#index
undefined local variable or method `per' for []:ActiveRecord::Relation
Rails.root: /Users/thomascioppettini/rails_projects/want-freight
Application Trace | Framework Trace | Full Trace
Request
Parameters:
{"order"=>"id_desc"}
Show session dump
Show env dump
Response
Headers:
None
The only thing I can think of that may affect the application is adding a recaptcha to devise, which active admin depends on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对我来说,这看起来像是一个分页问题。你用的是什么宝石?您应该提供有关您的设置的更多详细信息。您能向我们展示您的管理目录中的资源文件吗?您使用什么版本的 Rails 和 ActiveAdmin?
For me, it looks like this is a pagination problem. What gem are you using? You should give as more details about your settup. Can you show us your resource file from admin directory? What version of rails and what ActiveAdmin are you using ?
如果您使用 will_paginate gem,请将版本设置为 3.0.pre2。我使用的是
~>3.0.pre2
,当我运行bundle update
时,它会自动更新到3.0.2
恢复修复了问题。如果您使用的是 Bundler,则该行是这样的:If you are using the will_paginate gem, set the version to 3.0.pre2. I was using
~>3.0.pre2
, which auto-updated to3.0.2
when I ran abundle update
Reverting fixed the issue. If you're using Bundler, the line is this:我同意达瓦伊德的观点。这是一个分页错误。将“Kaminari”宝石添加到您的 Gemfile 中。根据活动管理文档,它使用 kaminari 进行分页.. will_paginate 也将为您工作,正如 swilliams 所描述的那样...
I agree with Dawaid. It is a pagiantion error. Add "Kaminari" gem to you Gemfile. According to active admin docs, it is using kaminari for pagination.. will_paginate will also work for you as swilliams described...
据我了解 active_admin 不再支持 will_paginate 。但是,如果您不想将分页重写为 Kaminari,您可以通过将一些代码放入初始值设定项来解决此问题
As I understand active_admin doesn't support will_paginate anymore. But if you don't want to rewrite your pagination to Kaminari you can fix this problem with putting some code to initializers