Wednesday, May 25, 2011

[Rails] indentify delayed_job with display_name

Hi,

I just found this solution for identifying a job in the job table:
http://stackoverflow.com/questions/3638250/how-to-cancel-scheduled-job-with-delayed-job-in-rails

They are using this code:

class MyJob < Struct.new(:user_id);
def perform
# ...
end

def display_name
return "MyJob-User-#{user_id}"
end
end

# store reference to a User
my_job = MyJob.new(User.first.id) # users.id is 1
job = Delayed::Job.enqueue(my_job, 0, 1.hour.from_now)
job.name
# => "MyJob-User-1"
job.handler
# => "--- !ruby/struct:MyJob \nuser_id: 1\n"

This is great and this is exactly what I need. I am just wondering
that I never read the display_name menthod before. Is that only for
the delayed_job objects or is that possible for every active record?

Where is that display_name stored?

Thanks in advance!
Sebastian

--
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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate