4
的錯誤,我得到:未定義的方法URL行動梅勒附件
ActionView::Template::Error (undefined method `url' for nil:NilClass)
我有這個附件是正在添加了零
<%= image_tag attachments['tippedlogods.png'].url %>
話雖這麼說,我已經宣佈的方法附件發送電子郵件,在這裏:
def confirmation(order)
@order = order
mail(to: @order.email, subject: "Order Confirmation", content_type: "text/html")
attachments.inline['tippedlogods.png'] = File.read("app/assets/images/tippedlogods.png")
end
在我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指南here ...
注意軌道4〜
鏈接是Rails 3的。也許有什麼改變?這裏是相關的部分:http://guides.rubyonrails.org/action_mailer_basics.html#complete-list-of-action-mailer-methods – Chloe