Я получаю ошибку:Неопределенного URL Метод действий Mailer Attachment
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 Guides here ...
Примечание Rails 4 ~
Ссылка была на Rails 3. Может быть, что-то изменилось? Вот соответствующий раздел: http://guides.rubyonrails.org/action_mailer_basics.html#complete-list-of-action-mailer-methods – Chloe