我必须从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)):
这是引起问题的行(下面的第二行)。
mail = SendGrid::Mail.new
mail.from = Email.new(email: 'no-reply@getburro.com') <-----
答案 0 :(得分:3)
Ruby正在寻找Email
类,但找不到它。原因是因为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