ROR:是什么导致未初始化的常量
ROR: What is causing uninitialized constant
我不得不从 Sendgrid V2 更新到 V3。我正在使用 Sendgrid-ruby gem 5.3。
我遇到了这个错误
NameError (uninitialized constant PasswordController::Email):
app/controllers/password_controller.rb:54:in `send_email'
May 06 08:57:01 burro-staging app/web.1: ArgumentError (wrong number of arguments (given 1, expected 0)):
这是导致问题的行(下面的第 2 行)。
mail = SendGrid::Mail.new
mail.from = Email.new(email: 'no-reply@getburro.com') <-----
Ruby 正在寻找 Email
class 但找不到。原因是因为 Email
属于 Sendgrid
模块,并且应该像这样限定范围:
Sendgrid::Email.new
...
在这里可以看到:
module SendGrid
class Email
attr_accessor :email, :name
def initialize(email: nil, name: nil)
...
来自文档:https://github.com/sendgrid/sendgrid-ruby#with-mail-helper-class
我不得不从 Sendgrid V2 更新到 V3。我正在使用 Sendgrid-ruby gem 5.3。
我遇到了这个错误
NameError (uninitialized constant PasswordController::Email):
app/controllers/password_controller.rb:54:in `send_email'
May 06 08:57:01 burro-staging app/web.1: ArgumentError (wrong number of arguments (given 1, expected 0)):
这是导致问题的行(下面的第 2 行)。
mail = SendGrid::Mail.new
mail.from = Email.new(email: 'no-reply@getburro.com') <-----
Ruby 正在寻找 Email
class 但找不到。原因是因为 Email
属于 Sendgrid
模块,并且应该像这样限定范围:
Sendgrid::Email.new
...
在这里可以看到:
module SendGrid
class Email
attr_accessor :email, :name
def initialize(email: nil, name: nil)
...
来自文档:https://github.com/sendgrid/sendgrid-ruby#with-mail-helper-class