设置一个变形SendGrid
意味着我们可以对 Rails 的文件命名方案进行例外处理。我们可以命名模型SendGrid...
而不必命名文件send_grid_...
。但是,它在此处引入了与依赖项相关的问题。我正在使用sendgrid-actionmailer
gem,它使用模块名称注册入口ActionMailbox::Ingresses::Sendgrid
,但前面的首字母缩写词定义意味着查找期望SendGrid
。
config/initializers/inflections.rb
:
# frozen_string_literal: true
ActiveSupport::Inflector.inflections(:en) do |inflect|
...
inflect.acronym 'SendGrid'
end
在生产中运行时,我使用 sendgrid-actionmailer:
/app/vendor/bundle/ruby/2.7.0/gems/actionmailbox-6.0.3.2/app/controllers/action_mailbox/ingresses/sendgrid/inbound_emails_controller.rb:47:in `<module:ActionMailbox>': uninitialized constant ActionMailbox::Ingresses::Sendgrid (NameError)
Did you mean? ActionMailbox::Ingresses::SendGrid
SendGrid
维护者建议这个问题更多地与 ActiveSupport 相关,而不是 sendgrid-actionmailer,我同意。他建议临时解决此问题的方法是删除首字母缩写词声明并改用 Sendgrid。是否有更永久的解决方案允许我们保留首字母缩写词声明?