Ruby on Rails - Access controller variable from model

后端 未结 5 997
深忆病人
深忆病人 2020-11-30 06:12

I am trying to access an instance variable which is set in the controller in the model. The controller is the products controller and the model is the products model. The in

5条回答
  •  被撕碎了的回忆
    2020-11-30 06:42

    I can't comment directly so I'll post here: the accepted answer does not seem to be right. As @vise notes, class variables are shared across requests. So unless there's just one current account for the entire app, this won't behave as expected.

    For more, see the accepted answer by @molf here: Is Rails shared-nothing or can separate requests access the same runtime variables?

提交回复
热议问题