不同用户之间共享的导轨是全局变量吗? [英] Is global variable in rails shared between different users?

查看:79
本文介绍了不同用户之间共享的导轨是全局变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个变量在我的Rails应用程序中被全系统使用。它运行良好,如果我只有一个用户使用该应用程序。如果有多个用户,则会弹出许多意想不到的问题。我没有得到任何错误日志,并且我有许多意外的行为。我相信大部分奇怪的回应都是由于全局变量的意外变化造成的。



我想知道,Rails中全局变量的值是由不同用户共享的吗?

谢谢〜

解决方案

这似乎取决于您的方法部署。



似乎mongrel和任何基于fastcgi的部署都会看到全局变量的不同实例,而乘客会分享它。这是基于#821820和许多关于rails和全局变量的文章,包括

I have few variables which are used system-wide in my rails app. It runs well if I just have one user using the app. If there are more then one user, many unexpected problem pop out. I don't get any error log, and I have many unexpected behaviors. I believe most of those strange response are due to unexpected change of global variable.

I would like to know, is the value of global variable in Rails shared between different users?

thanks~

解决方案

This seems to be dependant upon your method of deployment.

It seems that mongrel and any fastcgi based deployment will each see different instances of the global variable whereas passenger will share it. This is based upon #821820 and many articles on rails and global variables including this one.

To re-iterate what Eimantas said above, globals are generally a bad idea and you should consider another alternative, perhaps storing them in the database or session.

这篇关于不同用户之间共享的导轨是全局变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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