在后台执行ActionMailer::MailDeliveryJob
时调用类时出现以下错误:
[ActiveJob] [ActionMailer::MailDeliveryJob] [f158adfd-e4ac-4b0c-9c9b-5c4076f659d1] Error performing ActionMailer::MailDeliveryJob (Job ID: f158adfd-e4ac-4b0c-9c9b-5c4076f659d1) from Resque(default) in 733.75ms: NameError (uninitialized constant Railgun):
abc-web | /opt/abc-web/app/models/email_provider.rb:87:in `delivery_method_args'
abc-web | /opt/abc-web/app/mailers/user_mailer.rb:191:in `set_delivery_settings'
字符串
但它在控制台中加载得很好:
[2] pry(main)> ::Railgun::Mailer
=> Railgun::Mailer
型
如何让MailDeliveryJob
查看::Railgun::Mailer
类?
ICIM,这行代码片段:
# /opt/abc-web/app/models/email_provider.rb
82 def delivery_method_args
83 first_arg = case provider_type&.to_sym
84 when :smtp
85 :smtp
86 when :mailgun
87 ::Railgun::Mailer
88 else
89 raise "Unknown provider type #{provider_type}"
90 end
91 [first_arg, settings]
92 end
# /opt/abc-web/app/mailers/user_mailer.rb
181 def set_delivery_settings
182 tenant_email_provider = @user.tenant.email_providers.where(enabled: true).take
183
184 # Fall back to default configuration settings
185 return if tenant_email_provider.nil? || tenant_email_provider.settings.blank?
186
187 # This validation should probably done in the form
188 raise 'No server address to send to in smtp settings' if tenant_email_provider.server_address_missing?
189 raise 'No api key to send to in mailgun settings' if tenant_email_provider.api_key_missing?
190
191 delivery_method_args = tenant_email_provider.delivery_method_args
192 mail.delivery_method(*delivery_method_args)
193 end
的字符串
1条答案
按热度按时间xzlaal3s1#
容器完全重启即可。