私はRuby 1.9.3を使用しており、SendGrid APIを使用しようとしているときに次の行に次のエラーが表示されます。NoMethodError Ruby 1.9.3
NoMethodError (undefined method `to_h' for #<Hash:0x00000005da0958>):
CODE:[ "mailer.mail(mail_defaults)
" 以下、このライン上]
ERROR
と仮定し、一部のユーザー
recipients = []
recipient = SendGrid::Recipient.new('[email protected]')
recipient.add_substitution('name', 'Billy Bob')
recipient.add_substitution('number', 1234)
recipient.add_substitution('time', '10:30pm')
recipients << recipient
# then initialize a template
template = SendGrid::Template.new('blahblah7bef2-d25b00')
# create the client
# see client above
# set some defaults
mail_defaults = {
:from => '[email protected]',
:html => '<h1>I like email tests</h1>',
:text => 'I like email tests',
:subject =>'Test Email is great',
}
mailer = SendGrid::TemplateMailer.new(client, template, recipients)
# then mail the whole thing at once
mailer.mail(mail_defaults)
は、私はこれを試してみましたので、それは私のmail_defaults配列かもしれないと思いました(下記参照)、同じ行に同じエラーが発生しました。
mail_defaults = {
from: '[email protected]',
html: '<h1>I like email tests</h1>',
text: 'I like email tests',
subject: 'Test Email is great',
}
私のコードに誤りがありますか?それともSendGrids mailer.mailメソッドにエラーがありますか?
あなたは私たちに、完全なバックトレースを表示していただけますか? 'config/initializers/backtrace_silencers.rb'でbacktraceサイレンサーを削除する必要があるかもしれません。 – BoraMa