You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But trying to call it in an observer with a callback function:
classUserObserver < ActiveRecord::Observerdefbefore_save(user)ifuser.new_record?encrypt_confirmation_code(user)deliver(:password_forget,:password_forget_email,"Matthias","lordmatze@gmail.com")endend
...
end
or within a model:
classUser < ActiveRecord::Basedefsave_forget_password_token(user)self.password_reset_token=generate_authentity_tokenself.password_reset_token=1self.save# does not work :(deliver(:password_forget,:password_forget_email,"Matthias","lordmatze@gmail.com")endend
gives me the following error: undefined methoddeliver' for #UserObserver:0x007fc197881d18`
I added the observer in the app/app.rb file with the following line:
moduleJobVacancyclassApp < Padrino::Application
...
# Activating the user_observerActiveRecord::Base.add_observerUserObserver.instanceendend
Did I miss something? Or is there a missing loading path in Padrino core for observers and models?
The text was updated successfully, but these errors were encountered:
wikimatze
changed the title
Observers does not have access to mails from the mail generator
Observers and models does not have access to mails from the mail generator
Sep 20, 2014
The issue you're facing is that your model doesn't have access to the deliver helper your controller knows about. Calling JobVacancy::App.deliver(...) from your model or observer should do the job. We should probably document that better @padrino/core-members; sorry about that.
I'm using the latest padrino version 0.12.3 and have the following defined mailer:
Using it in a controller like the following works fine:
But trying to call it in an observer with a callback function:
or within a model:
gives me the following error:
undefined method
deliver' for #UserObserver:0x007fc197881d18`I added the observer in the
app/app.rb
file with the following line:Did I miss something? Or is there a missing loading path in Padrino core for observers and models?
The text was updated successfully, but these errors were encountered: