显示器具有许多关联的activeadmin rails,它们不能在暂存中工作,但在本地和开发中可以正常工作 [英] Display has to many association activeadmin rails not working in staging but works fine in local and development

查看:100
本文介绍了显示器具有许多关联的activeadmin rails,它们不能在暂存中工作,但在本地和开发中可以正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可以具有许多身份的用户(取决于他们是否使用Facebook,Google或我的网站登录)。在ActiveAdmin中显示身份,我有以下代码。

I have users which can have many identities, (depending on whether they login using facebook, google, or my site). In ActiveAdmin to display the identities I had the following code.

ActiveAdmin.register User do
menu label: 'Subscribers'
ActiveAdmin.register Identity do
belongs_to :user
 end 


index do
selectable_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
column "Sign-up Provider", :identities do |user|
      ul do

         user.identities.collect  do |identity|
             li do 
                 if identity.provider == "gplus"
                   "Google"
                 else identity.provider == "facebook"
                  identity.provider.capitalize
                 end
            end   
          end
         "Self"
       end
 end
actions
end

form do |f|
  f.inputs 'User Details' do
  f.input :email
  f.input :password
  f.input :password_confirmation
  end
  f.actions
 end
end

在本地主机上工作正常,并且远程开发环境。但是在使用生产环境的登台运行时给出502错误。
看到日志,似乎查询需要很长时间。试图弄清楚为什么要花费更长的时间,似乎要对每个用户一次又一次地执行获取身份的查询,这是一种低效的方式。我们还尝试了在阶段使用数据并将其导入本地和开发环境中,以查看是否是导致错误的数据大小,但仍然可以在此处使用。我了解查询效率低下。实现此目标的正确方法是什么?

It works fine in the local host, and a remote development environment. But gives 502 error when run on staging which uses the production environment. seeing the log it seems the query takes long time. Trying to figure out why does it take longer time, it appeared as if the query to fetch the identity is executed for each user again and again, which is kind of an inefficient way. We also tried using the data at the staging and importing it in the local and development enviroment to see if it is the data size that is causing error, but it still works there. I understand the query is inefficient. What is the correct way to achieve this?

如果我使用的是正确的方法,请帮助我解决错误。谢谢。

And if what I have used is the correct way to go for it, please help me resolve the error. Thanks.

令人惊讶的是,如果我删除身份列,则不会发生此错误。

Surprisingly, this error does not occur if i remove the identities column.

推荐答案

嗯,这个问题有非常不寻常的解决方案,可能与这个问题没有特别的联系,但是可以。

Well, this problem had quite unusual solution, probably not specifically related to this problem but yes

问题出在内存上。在服务器上,磁盘空间已被过度使用。我们通过删除一些旧的日志文件释放了一些内存,并且还使用了 pluck 代替了 collect ,只是为了获取所需的提供者,而不是整个记录。

The problem was with memory. On the server, the disk space became over-exceedingly used. We freed some memory by deleting some old log files, and also, used pluck instead of collect, just to fetch only the needed "provider" instead of the whole record.

这篇关于显示器具有许多关联的activeadmin rails,它们不能在暂存中工作,但在本地和开发中可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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