I tried passing the session id around to the model, and agree that it is
very ugly.

I am curious to know how you can best achieve this scenario without passing
in the session variable: abort a delayed_job (or other model based) work
item when user changes something - this is mainly required because delayed
job workers cost money at my host (heroku) and if the user randomly clicks
around on the UI, I dont want to be billed for all the spawned jobs that no
one cares about anyway.

Thanks
Anand

On Tue, Jun 29, 2010 at 10:37 AM, Anand Ramanathan <li...@ruby-forum.com>wrote:

> Hi,
>
> 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
> time.
>
> 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.
>
> Thanks
> Anand
>
> Pratik Naik wrote:
> > Hey David,
> >
> > Sorry, I didn't mean to quote you ( just pressed gmail reply button ).
> > My message was not for you, but for the people using the code :)
> >
> > On Tue, Jul 29, 2008 at 5:36 PM, David A. Black <dbl...@rubypal.com>
> > wrote:
> >>>>
> >>>>
> >> thinking that the method and variable names were being hurled at a
> >>  * Co-taught by D.A. Black and Erik Kastner
> >> See http://www.rubypal.com for details and updates!
> >>
> >> >
> >>
> >
> >
> >
> > --
> > Cheers!
> > - Pratik
> > http://m.onkey.org
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to