Ruby on rails 操作邮件程序附件的未定义方法URL
我得到的错误是:Ruby on rails 操作邮件程序附件的未定义方法URL,ruby-on-rails,ruby-on-rails-4,actionmailer,Ruby On Rails,Ruby On Rails 4,Actionmailer,我得到的错误是: ActionView::Template::Error (undefined method `url' for nil:NilClass) 我的附件是零 <%= image_tag attachments['tippedlogods.png'].url %> 在my production.rb中: config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery
ActionView::Template::Error (undefined method `url' for nil:NilClass)
我的附件是零
<%= image_tag attachments['tippedlogods.png'].url %>
在my production.rb中:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => 'hidden-peak-xxxx.heroku.com', :only_path => false}
config.action_mailer.asset_host = 'hidden-peak-xxxx.heroku.com'
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 587,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN'],
:authentication => :plain
}
这不是在确认电子邮件中发送图像的方式吗
我在跟随RoR指南
注意Rails 4~在添加附件之前,您首先要呼叫
邮件。因此,在呈现模板时没有附件
更改语句的顺序
attachments.inline['tippedlogods.png'] = File.read("app/assets/images/tippedlogods.png")
mail(to: @order.email, subject: "Order Confirmation", content_type: "text/html")
链接到Rails 3。也许有什么改变了?以下是相关章节:
attachments.inline['tippedlogods.png'] = File.read("app/assets/images/tippedlogods.png")
mail(to: @order.email, subject: "Order Confirmation", content_type: "text/html")