简体   繁体   English

主动管理员弹出奇怪的错误

[英]weird error popped up with active admin

I am using active_admin and devise in a project. 我正在使用active_admin并在项目中进行设计。 There is an admin page to invite users that won't even load at all. 有一个管理页面可以邀请甚至根本不加载的用户。 I have tried removing quite a bit of code to get some clues as to what is going on. 我已经尝试删除相当多的代码,以获得有关正在发生的事情的线索。 All I get is the following error. 我得到的是以下错误。

NoMethodError in Admin/invitations#index

Showing /Users/ianseabock/.rvm/gems/ruby-1.9.3-p448/gems/activeadmin-0.6.2/app/views/active_admin/resource/index.html.arb where line #1 raised:

undefined method `storage_total_stat_id_eq' for #<MetaSearch::Searches::User:0x007fb9ebde5ce0>
Extracted source (around line #1):

1: insert_tag renderer_for(:index)

The undefined method "storage_total_stat_id_eq" is no where to be found in the codebase. 未定义的方法“storage_total_stat_id_eq”无法在代码库中找到。 Any suggestions on what's going on? 有关正在发生的事情的任何建议?

It sounds like this is caused by an association that Active Admin is trying to build a filter for, but I'm guessing the association is non-standard. 听起来这是由Active Admin试图为其构建过滤器的关联引起的,但我猜这种关联是非标准的。 You can see which filters are being built by default with this bit of code: 您可以使用以下代码查看默认情况下正在构建的过滤器:

ActiveAdmin.application.namespaces[:admin].resources[:User].filters

A quick fix would be to remove that filter: 快速解决方法是删除该过滤器:

ActiveAdmin.register User do
  # ...

  remove_filter :storage_total_stat

  # ...
end

Check to see if you have included the storage_total_stat_id has been included in the permitted parameters: 检查是否已包含storage_total_stat_id已包含在允许的参数中:

ActiveAdmin.register Invitation do
    permit_params :storage_total_stat_id, :other, :attributes, :for, :this, :model
end

I had a similar problem - and for me it was that my Active Admin form included a "collection" filter that was incorrectly specified. 我遇到了类似的问题 - 对我而言,我的Active Admin表单中包含一个错误指定的“集合”过滤器。

I had used User.all.where(...) instead of User.where(...). 我使用过User.all.where(...)而不是User.where(...)。

Once I removed the ".all", it fixed the problem. 一旦我删除了“.all”,它就解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM