Genji
2011-Aug-15 12:10 UTC
Delayed_Job: code working fine without .delay / with .delay it fails. Why?
Hi all, I wrote a simple code to set up the "pit_id" from a village table from 1 to 2, from 2 to 3 and so on. It works fine without .delay . But i need it so whats wrong with that code? #village_controller def post_info @village = Village.find(params[:id]) @village.delay.upgrade flash[:notice] = "Upgrading" redirect_to village_url(@village) end #village.rb def upgrade sleep 3 update_attribute(:pit_id, pit_id + 1) end I''ve heard that there could be problems with the variables when using delay ? I already tried @village.delay.upgrade(@village) -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Aug-15 12:19 UTC
Re: Delayed_Job: code working fine without .delay / with .delay it fails. Why?
On Aug 15, 1:10 pm, Genji <sushi.ge...-PkbjNfxxIASELgA04lAiVw@public.gmane.org> wrote:> Hi all, > > I wrote a simple code to set up the "pit_id" from a village table from > 1 to 2, from 2 to 3 and so on. > It works fine without .delay . But i need it so whats wrong with that > code? > > #village_controller > def post_info > @village = Village.find(params[:id]) > @village.delay.upgrade > flash[:notice] = "Upgrading" > redirect_to village_url(@village) > end > > #village.rb > def upgrade > sleep 3 > update_attribute(:pit_id, pit_id + 1) > end > > I''ve heard that there could be problems with the variables when using > delay ? >In what way does it not work ? Fred> I already tried @village.delay.upgrade(@village)-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Genji
2011-Aug-15 12:32 UTC
Re: Delayed_Job: code working fine without .delay / with .delay it fails. Why?
On 15 Aug., 14:19, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 15, 1:10 pm, Genji <sushi.ge...-PkbjNfxxIASELgA04lAiVw@public.gmane.org> wrote: >Well the problem WAS that it didn''t do anything, the worker just told me: [Worker(host:Sascha-Gundels-MacBook-Pro.local pid:961)] 2 jobs processed at 96.8147 j/s, 2 failed ... But it changed now. All I did was setting up /config/initializers/delayed_job_config.rb to: Delayed::Worker.destroy_failed_jobs = false Delayed::Worker.sleep_delay = 60 Delayed::Worker.max_attempts = 3 Delayed::Worker.max_run_time = 5.minutes and restart the worker ^^'' Sorry for asking - it works now..> > > > > > > > > Hi all, > > > I wrote a simple code to set up the "pit_id" from a village table from > > 1 to 2, from 2 to 3 and so on. > > It works fine without .delay . But i need it so whats wrong with that > > code? > > > #village_controller > > def post_info > > @village = Village.find(params[:id]) > > @village.delay.upgrade > > flash[:notice] = "Upgrading" > > redirect_to village_url(@village) > > end > > > #village.rb > > def upgrade > > sleep 3 > > update_attribute(:pit_id, pit_id + 1) > > end > > > I''ve heard that there could be problems with the variables when using > > delay ? > > In what way does it not work ? > > Fred > > > > > > > > > I already tried @village.delay.upgrade(@village)-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Maybe Matching Threads
- delayed_job - Undefined method error even with Mongrel
- Delayed_job: how to raise and log exceptions
- indentify delayed_job with display_name
- Rails 3 - Delayed_Job (collectiveidea), trying to Delay Mailers - Error: NoMethodError (undefined method `delay' for UserMailer:Class):
- Delayed_Jobs Failed: Where to Check Logs/Errors?