将导轨从6.1.1升级到7.0.3之后,我的设计邮件可以初始化
我开始将我的申请升级为6.1.1至7.0.3。在执行此操作时,我还必须升级从4.7.3
升级到4.8.1
。
有了旧设置,一切都很好。现在升级后,我无法启动以下内容:
- Rails Server
- Rails Console
- RSPEC Specs
- rake rails:更新
它们都失败了以下错误消息:
/home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/activesupport-7.0.3/lib/active_support/inflector/methods.rb:280:in `constantize': uninitialized constant AccountMailer
Did you mean? ActionMailer (NameError)
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/activesupport-7.0.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/devise-4.8.1/lib/devise.rb:320:in `get'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/devise-4.8.1/lib/devise.rb:343:in `mailer'
from /home/andres/apps/my_app/config/initializers/devise.rb:25:in `block in <main>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/devise-4.8.1/lib/devise.rb:307:in `setup'
from /home/andres/apps/my_app/config/initializers/devise.rb:5:in `<main>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:667:in `block in load_config_initializer'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/activesupport-7.0.3/lib/active_support/notifications.rb:208:in `instrument'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:666:in `load_config_initializer'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:619:in `each'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:619:in `block in <class:Engine>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `instance_exec'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `run'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:61:in `block in run_initializers'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `each'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `tsort_each_child'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:415:in `call'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `call'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:60:in `run_initializers'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/application.rb:372:in `initialize!'
from /home/andres/apps/my_app/config/environment.rb:7:in `<main>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from <internal:/home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>'
Mailer Files: Mailer Files
我正在使用以下Mailer-folder结构:
app/mailers:
account_mailer.rb
application_mailer.rb
我的councel_mailer.rb有以下声明:
# frozen_string_literal: true
# using SendGrid's Ruby Library
# https://github.com/sendgrid/sendgrid-ruby
require 'sendgrid-ruby'
class AccountMailer < Devise::Mailer
include SendGrid
default template_path: 'devise/mailer'
基于Constance
方法应该能够完成我所需要的一切(文件名与类名称匹配,文件在正确的文件夹结构下存在)。
使用Mailer设计初始化
我的自定义accountmailer
在Deaties Initializer中初始化了这样的初始化:config.mailer ='accountMailer'
。
正如我所说的 - 这一切都像Rails 6.1.1中的魅力一样工作,但是现在我无法在Rails升级后围绕问题所在。
我尝试的是:
我评论了所有 accountmailer
参考。之后,我开始遇到有关deaise ::这样的错误
An error occurred while loading rails_helper.
Failure/Error: require File.expand_path('../config/environment', __dir__)
NameError:
uninitialized constant Devise::Mailer
Did you mean? Devise::Mailers
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/activesupport-7.0.3/lib/active_support/inflector/methods.rb:280:in `constantize'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/activesupport-7.0.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/devise-4.8.1/lib/devise.rb:320:in `get'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/devise-4.8.1/lib/devise.rb:343:in `mailer'
# ./config/initializers/devise.rb:25:in `block in <main>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/devise-4.8.1/lib/devise.rb:307:in `setup'
# ./config/initializers/devise.rb:5:in `<main>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:667:in `block in load_config_initializer'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/activesupport-7.0.3/lib/active_support/notifications.rb:208:in `instrument'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:666:in `load_config_initializer'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:619:in `each'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:619:in `block in <class:Engine>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `instance_exec'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `run'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:61:in `block in run_initializers'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `each'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `tsort_each_child'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:60:in `run_initializers'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/application.rb:372:in `initialize!'
# ./config/environment.rb:7:in `<top (required)>'
# ./spec/rails_helper.rb:8:in `require'
# ./spec/rails_helper.rb:8:in `<top (required)>'
的
# config.mailer = 'AccountMailer'
# config.mailer.perform_deliveries = !Rails.env.test?
# config.mailer.raise_delivery_errors = true
错误100%工作所需的工作。
我检查了 Deweise ChangElog 在4.7.3之后发行了我的版本升级从那里升级,我没有注意到那里的任何相关更改。
我还检查了版本6.1.1和7.0.3之间的相关配置更改,
constandize
在错误跟踪中出现的方法在此处描述: https://api.rubyonrails.org/classes/string.html#method-i-constantize
我正在将Rails升级教程从在这里。 这里有什么问题?
I started upgrading my application from Rails 6.1.1 to 7.0.3. While doing this I also had to upgrade Devise from 4.7.3
to 4.8.1
.
With old setup everything worked fine. Now after upgrading I can't start none of the following:
- rails server
- rails console
- rspec specs
- rake rails:update
They all fail with the following error message:
/home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/activesupport-7.0.3/lib/active_support/inflector/methods.rb:280:in `constantize': uninitialized constant AccountMailer
Did you mean? ActionMailer (NameError)
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/activesupport-7.0.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/devise-4.8.1/lib/devise.rb:320:in `get'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/devise-4.8.1/lib/devise.rb:343:in `mailer'
from /home/andres/apps/my_app/config/initializers/devise.rb:25:in `block in <main>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/devise-4.8.1/lib/devise.rb:307:in `setup'
from /home/andres/apps/my_app/config/initializers/devise.rb:5:in `<main>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:667:in `block in load_config_initializer'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/activesupport-7.0.3/lib/active_support/notifications.rb:208:in `instrument'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:666:in `load_config_initializer'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:619:in `each'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/engine.rb:619:in `block in <class:Engine>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `instance_exec'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `run'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:61:in `block in run_initializers'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `each'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `tsort_each_child'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:415:in `call'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `call'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
from /home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/initializable.rb:60:in `run_initializers'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/railties-7.0.3/lib/rails/application.rb:372:in `initialize!'
from /home/andres/apps/my_app/config/environment.rb:7:in `<main>'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /home/andres/.rvm/gems/ruby-3.0.0@my_app/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from <internal:/home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/home/andres/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>'
Mailer files
I'm having the following mailer-folder structure:
app/mailers:
account_mailer.rb
application_mailer.rb
My account_mailer.rb has the following declaration:
# frozen_string_literal: true
# using SendGrid's Ruby Library
# https://github.com/sendgrid/sendgrid-ruby
require 'sendgrid-ruby'
class AccountMailer < Devise::Mailer
include SendGrid
default template_path: 'devise/mailer'
Based on that the constantize
method should be able to do all it needs to I understand (file names match the class name, files are present under correct folder structure).
Devise initialization with mailer
My custom AccountMailer
is initialized inside Devise initializer like this: config.mailer = 'AccountMailer'
.
As I said- this all worked like a charm in Rails 6.1.1 but now I can't get my head around what's wrong after the Rails upgrade.
What I've tried:
I commented out all the AccountMailer
references. After that I started getting errors about Devise::Mailer like this (in RSpec):
An error occurred while loading rails_helper.
Failure/Error: require File.expand_path('../config/environment', __dir__)
NameError:
uninitialized constant Devise::Mailer
Did you mean? Devise::Mailers
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/activesupport-7.0.3/lib/active_support/inflector/methods.rb:280:in `constantize'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/activesupport-7.0.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/devise-4.8.1/lib/devise.rb:320:in `get'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/devise-4.8.1/lib/devise.rb:343:in `mailer'
# ./config/initializers/devise.rb:25:in `block in <main>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/devise-4.8.1/lib/devise.rb:307:in `setup'
# ./config/initializers/devise.rb:5:in `<main>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:667:in `block in load_config_initializer'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/activesupport-7.0.3/lib/active_support/notifications.rb:208:in `instrument'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:666:in `load_config_initializer'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:619:in `each'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/engine.rb:619:in `block in <class:Engine>'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `instance_exec'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:32:in `run'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:61:in `block in run_initializers'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `each'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:50:in `tsort_each_child'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/initializable.rb:60:in `run_initializers'
# /home/andres/.rvm/gems/ruby-3.0.0@vaab/gems/railties-7.0.3/lib/rails/application.rb:372:in `initialize!'
# ./config/environment.rb:7:in `<top (required)>'
# ./spec/rails_helper.rb:8:in `require'
# ./spec/rails_helper.rb:8:in `<top (required)>'
When I commented out all the Devise mailer configuration lines in Devise initializer like this:
# config.mailer = 'AccountMailer'
# config.mailer.perform_deliveries = !Rails.env.test?
# config.mailer.raise_delivery_errors = true
Then only at that point my application seemed to work 100% as it needs to.
I checked the Devise changelog for releases after 4.7.3 that I was upgrading from and I didn't notice any relevant changes there.
I also checked Rails mailer related configuration changes between versions 6.1.1 and 7.0.3 from release notes and I again didn't notice anything that might affect.
The constantize
method that appears in error trace is described here: https://api.rubyonrails.org/classes/String.html#method-i-constantize
I'm taking the Rails upgrade tutorial as basis from here.
What could be the issue here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置类名之后,下一行中的getter
config.mailer
constandizes中,因为它需要类对象。在Rails 6.0和6.1中,该访问引起了嘈杂的警告,在启动期间自动加载了可重新加载的课程。在Rails 7中,弃用周期完成,并在引导过程中自动加载可重新加载的类或模块是错误条件。
一种可能的解决方案是预加载带有
的Mailer需要
在初始化器中调用以进行设计。自动加载器将看到accountmailer
已经加载,并且会忽略account_mailer.rb
。理由是
accountmailer
无法重新加载,因为重新加载的更改不会产生效果,因为在重新加载初始化器未运行的情况下。此错误阻止了不引起注意的情况。After setting the class name, the getter
config.mailer
in the next line constantizes, because it needs the class object.In Rails 6.0 and 6.1, that access got a noisy warning, autoloading a reloadable class during boot got deprecated. In Rails 7, the deprecation cycle finished, and autoloading a reloadable class or module during boot is an error condition.
One possible solution is to preload that mailer with a
require
call in the initializer for Devise. The autoloader will seeAccountMailer
was already loaded, and will ignoreaccount_mailer.rb
.The rationale is that
AccountMailer
cannot be reloadable, because reloaded changes would have no effect, since on reload that initializer does not run. This error prevents introducing this incongruence without noticing.