ruby on rails - Delayed Job Gem: Undefined Method 'perform' for Class -


i successful integration delayed_job mailer (app > mailers > notification_mailer.rb), has single method:

class notificationmailer < actionmailer::base   default from: env["gmail_username"]    def notification_message(activity, user)     @user = user     @activity = activity       if @activity.is_comment?         subject = @activity.trackable.user.username + ' commented on ' + @activity.trackable.commentable.project.title       @type = "comment"     end      mail(to: @user.email, subject: subject)   end  end 

i call in controller, example:

notificationmailer.delay.notification_message(@activity, user) 

however, i'm having issues using delayed_job non mailer jobs. created folder in app > jobs i've placed classes, such as:

class carrierwaveimageuploader     def execute(image_id, s3_url)         if image.exists?(image_id)             @image = image.find(image_id)             @image.remote_image_path_url = s3_url             @image.update_column(:rotation, nil)             @image.save         end     end     handle_asynchronously :execute end 

but when try call method in controller with

carrierwaveimageuploader.delay.execute(@image.id, s3_image_url) 

i error

nomethoderror (undefined method `execute' carrierwaveimageuploader 

i using delayed_job 4.1.2 , have restarted delayed_job.

def execute instance method, not class method.

carrierwaveimageuploader.delay.execute(@image.id, s3_image_url)

doesn't work because class carrierwaveimageuploader doesn't have execute method.

uploader = carrierwaveimageuploader.new uploader.delay.execute(@image.id, s3_image_url) 

should work, creates instance , calls execute method.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -