I have a scenario where the session variable is handy in the model - I
need to be able to get the current value, as it may be changed at any
I have a delayed_job that runs a long running model activity (calling
multiple web services, populating the database, etc.) in the background.
This is triggered when a user selects an item from a list in the UI.
However, if the user clicks on another item, I want the current
processing to stop, as I want to keep the delayed_job worker pool as
free as possible (the more the jobs, the more I am billed by the
hoster). The only way I can see to achieve this is to set a session
variable (session[:current_topic_id]) when the user clicks on a topic,
and then check in each stage of the model action if the current topic is
the same as the one stored in the session, and abort the long job if
they are out of sync.
Here, passing in the session variable to the model method wont really
work for me, I have to pass in the session id and check the variable
value across the model code.
Pratik Naik wrote: