After upgrading to Rails 6 I am noticing that default mailer's .deliver_later
is not working the same as in Rails 5.
Configuration:
config.active_job.queue_adapter = :inline
When running Mailer.register_email(...).deliver_later
- nothing is stored in ActionMailer::Base.deliveries
. This array gets filled if I run perform_enqueued_jobs
- it seams like queue_adapter = :inline
doesn't work the way I expect it to work.
If I run Mailer.send(...).deliver_now
then ActionMailer::Base.deliveries
has proper value in it.
Any idea why this is happening and how to solve this?
Rails 6 release date and features. 1 1) Action Mailbox. In Rails 5, we were using ActionMailer to manage mails in the application. Action Mailbox is extracted from Basecamp, which gives ... 2 2) Action Text. 3 3) Parallel Testing. 4 4) Action Cable Testing. 5 5) Webpack.
Rails 6 latest version rc2 has now released on July 22, 2019. This may be the best-exercised RC (release candidate) in Rails history. Because Rails has been released with three beta versions so far. Companies like Basecamp, Shopify and Github already using rc1 in the production.
First, you need to consider your application rails version is 5.2 and you need to upgrade to rails version 6. And your current app rails version has latest patch version before moving to the next major/minor version. Rails 6 require Ruby version 2.5 or greater. You need to check all your gems from Gemfile are compatible with Rails 6 gem.
Since Ruby on Rails has been around for years, few people expect revolutionary changes, but its sixth incarnation brings a lot to the table. Some features rolled out in Rails 6 seem like minor improvements, while others have the potential to save a lot of development time, improve security, robustness, and so on.
I had same problem in my tests. A search on the Internet yielded nothing, so I started experimenting.
I tried wrapping the call method of sending mail in
assert_emails 1 do
Mailer.register_email(...).deliver_later
end
After that, ActionMailer::Base.deliveries
populated correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With