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
I'm trying to add hanami-mailer to my project, however I seem to have found a bug.
When I try to deliver email I get an exception App::Mail::Mailers::Foo::Bar.deliver
NoMethodError: undefined method `fetch' for nil:NilClass
from /home/graudeejs/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-mailer-1.3.1/lib/hanami/mailer/dsl.rb:85:in `templates'
However if I call .templates before .deliver it works
Hi @graudeejs, thanks for your bug report and the time spent to create a sample project.
What I could find there are 2 issues in there:
The mailers need to be loaded before the call to Hanami::Mailer.load!.
Zeitwerk (maybe)
hanami-mailer 1.x series keeps references to the included classes by subverting the included hook. So when load! is called a call to templates with no args is sent. The thing is this call is triggered on all classes that Hanami::Mailer was included (which in your example would be none as they would be loaded after).
I'm not sure that you can make Zeitwerk actually load the classes beforehand.
That being said, this all is changing on hanami-mailer 2.0, that you can check on the unstable branch
Hello!
I'm trying to add hanami-mailer to my project, however I seem to have found a bug.
When I try to deliver email I get an exception
App::Mail::Mailers::Foo::Bar.deliver
However if I call
.templates
before.deliver
it worksI've created a small repo where this issue can be replicated:
https://github.com/graudeejs/hanami-mailer-issue-79
The text was updated successfully, but these errors were encountered: