I'd like @report_for to stick around for an entire session
- I created a method called "report4" in my application_controller which is used to se开发者_开发技巧t my "@report_for" variable
- in another controller, "report4" is called with a before_filter for a view
- In the view it displays as part of the heading
- 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
精彩评论