rubyonjets/jets

Freshly generated --mode job app fails to send mails, missing ApplicationHelper

Closed this issue · 3 comments

Checklist

  • Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a jets upgrade command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/
  • Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.rubyonjets.com
  • Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.

My Environment

Software Version
Operating System macOS Catalina 10.15.7
Jets 2.3.18
Ruby 2.7.0

Expected Behaviour

After generating a new project via --mode job, be able to then generate a mailer and send the mail via the console

Current Behavior

ApplicationHelper is not created with --mode job and therefor creates an error when attempting to send a mail. See the error log below for more info.

Step-by-step reproduction instructions

jets new mail_test --database=postgresql --mode job
jets generate mailer TestMailer test_mail
jets c
TestMailer::test_mail.deliver_now

Error Log
irb(main):006:0> TestMailer::test_mail.deliver_now
D, [2021-01-18T16:02:30.892923 #75972] DEBUG -- : TestMailer#test_mail: processed outbound mail in 8.5ms
Traceback (most recent call last):
       16: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-6.1.1/lib/action_view/lookup_context.rb:258:in `block in initialize_details'
       15: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-6.1.1/lib/action_view/lookup_context.rb:51:in `block in <class:LookupContext>'
       14: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/jets-3.0.2/lib/jets/core_ext/kernel.rb:11:in `require'
       13: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
       12: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
       11: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-6.1.1/lib/action_view/base.rb:12:in `<top (required)>'
       10: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-6.1.1/lib/action_view/base.rb:141:in `<module:ActionView>'
        9: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-6.1.1/lib/action_view/base.rb:279:in `<class:Base>'
        8: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
        7: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
        6: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
        5: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.1/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
        4: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.1/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
        3: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.1/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
        2: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.1/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
        1: from /.../.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/jets-3.0.2/lib/jets/controller/rendering/rack_renderer.rb:220:in `block in setup!'
NameError (uninitialized constant ApplicationHelper)
Did you mean?  ApplicationMailer

Code Sample

Nothing was changed from a freshly generated app.

Solution Suggestion

Generate the ApplicationHelper when generating with --mode job

Changing to Ruby 2.5.8 fixed the issue

I have hit the same issue with the missing ApplicationHelper. Switching to Ruby 2.5.8 is not an option as it reached EOL. The proper solution is to generate app/helpers/application_helper.rb

Fixed in #674