开发者

I'd like @report_for to stick around for an entire session

  1. I created a method called "report4" in my application_controller which is used to se开发者_开发技巧t my "@report_for" variable
  2. in another controller, "report4" is called with a before_filter for a view
  3. In the view it displays as part of the heading
  4. I thought that it would still be present when data is sent back to the controller for an update, but "@report_for" is coming up nil.

Can, and should, a variable like "@report_for" be set to exist for the entire session like "current_user"?

If not, is the best way to send it back in a hidden field?

Thanks.


you can just use the session hash (ActionDispatch::Session::AbstractStore::SessionHash):

session[:report_for] = 'whatever'
if session[:report_for].present?
  #do your thing
else
  #carry on
end
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜