Do you need a session variable as part of your model or as a flag to determine what needs to be done?
If the first, you donβt need to know where the parameters came from, just pass the variable as an argument for some call in your method. For instance:
@user = User.new(params[:user].merge(:some_attribute => session[:some_key])
and just add validation, as usual, to the model.
If you need to control some thread of execution, since you mention that it should be different for different users, you may need an instance variable in your controller. Sort of
class SomeController before_filter :set_some_session_variable def set_some_session_variable @some_variable = session[:some_key] end end
You can use session[:some_key] directly in your view, but it is better to set it in an instance variable.
source share