开发者

Is global variable in rails shared between different users?

I have few variables which are used system-wide in my rails app. It runs well if I just ha开发者_运维知识库ve 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.


Global variables are a sign of [very/really] bad design. Have you considered SimpleConfig gem for this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜