Closed asiniy closed 12 years ago
Jobs are deleted after they complete successfully. Sounds like it is running correctly. Maybe create is returning false for validation reasons? Try create! If it is an active record call.
Daniel Morrison [i] Collective Idea http://collectiveidea.com http://ideafoundry.info 25 West 8th Street, Suite 200 Holland, MI 49423 616-990-0155 daniel@collectiveidea.com
On Mar 31, 2012, at 12:24 PM, Alex Antonovreply@reply.github.com wrote:
Hi!
I have some trouble. I create delayed job, run it, but with no effect. I saw the common problems article in wiki, but with no help.
Gemfile: gem 'delayed_job_active_record'
First: model Something
class Something < ActiveRecord::Base def create_something(txt) create do |something| text = txt end end handle_asynchronously :create_something, :run_at => Proc.new { 1.minutes.from_now } end
Second: controller pages, action 'create'
def create smth = Something.new smth.create_something(params[:text]) redirect_to root_path end
So, when I send POST to pages path, I see new record in delayed_jobs table: id: 10 prority: 0 attempts: 0 handler: --- !ruby/object:Delayed::PerformableMethod object: !ruby/ActiveRecord:Something attributes: id: text: when_created: created_at: updated_at: method_name: :create_something_without_delay args:
- fripokaioj
where 'fripokaioj' - random text that I put in text field
et.c.
After a minute(:run_at => Proc.new { 1.minutes.from_now }) record disappearence. But with no changes in database. Why?
I try both: script/delayed_job start and rake jobs:work.
WIthout any effect. Log is empty.
What's wrong?
Reply to this email directly or view it on GitHub: https://github.com/collectiveidea/delayed_job/issues/372
I provided you my model code, there aren't validations here.
With create! similar effect. No changes in somethings table, and record from delayed_jobs is removed
Daniel, could you give the code of successfully worked app with delayedjob?
I'm not sure what your create_something method is supposed to do. You're calling create, which is an instance method in that context. You code might not be doing what you expect.
Daniel Morrison [i] Collective Idea http://collectiveidea.com http://ideafoundry.info 25 West 8th Street, Suite 200 Holland, MI 49423 616-990-0155 daniel@collectiveidea.com
On Mar 31, 2012, at 1:09 PM, Alex Antonovreply@reply.github.com wrote:
I provided you my model code, there aren't validations here.
With create! similar effect. No changes in somethings table, and record from delayed_jobs is removed
Reply to this email directly or view it on GitHub: https://github.com/collectiveidea/delayed_job/issues/372#issuecomment-4859875
Daniel, I changed it:
model: self.create_something(txt)
controller: Something.create_something(params[:text])
but if I did this, how I can attach handle_asynchronously to code?
It writes to me: undefined method create_something' for class
Something'
create do |something|
text = txt <------- assigns to a local variable. doesn't do anything!
end
Closing as an open issue but, by all means, continue the discussion if desired.
Matt, dj still not work. Please reopen the issue.
I did this: def create_something(txt) Something.destroy_all end handle_asynchronously :create_something, :run_at => Proc.new { 1.minutes.from_now } But still don't work. DJ fill in and fill out records in delayed_jobs table, but without any changings in somethings table
Alex, you cannot defer methods on unsaved models but you can defer the creation of a model as you seem to be trying to do. I think what you want is: Something.delay.create :text => 'my text'
If you still have questions, please post it on StackOverflow and drop a link here.
Hi!
I have some trouble. I create delayed job, run it, but with no effect. I saw the common problems article in wiki, but with no help.
Gemfile: gem 'delayed_job_active_record'
First: model Something
Second: controller pages, action 'create'
So, when I send POST to pages path, I see new record in delayed_jobs table: id: 10 prority: 0 attempts: 0 handler: --- !ruby/object:Delayed::PerformableMethod object: !ruby/ActiveRecord:Something attributes: id: text: when_created: created_at: updated_at: method_name: :create_something_without_delay args:
where 'fripokaioj' - random text that I put in text field
et.c.
After a minute(:run_at => Proc.new { 1.minutes.from_now }) record disappearence. But with no changes in database. Why?
I try both: script/delayed_job start and rake jobs:work.
WIthout any effect. Log is empty.
What's wrong?