Rails: attachments.inline[] in mail

actionmailer, ruby-on-rails-3

Solution

attachments and inline attachments differs only that inline will insert it via base64 but you need to attach a file anyhow to it!

  attachments.inline['mealnut.png'] = File.read( Rails.root.join("app/some/path/","mealnut.png") )

than you are able to reference it in the view

hope that helped!

Problem

I am looking for displaying company logo in the email when email is sent. I went thought action mailer base and there is attachment inline feature which supports images in mail. I implemented it in this way: in user_mailer.rb ``` def welcome_email(user) @user = user @url = "http://mealnut.com" attachments.inline['mealnut.png'] mail(:to => user.email, :subject => "Mealnut: New Order #{order.id}") end ``` in config/application.rb: ``` config.action_mailer.default_url_options = { :host => "mealnut.com" } ``` in welcome_email.html.web ``` <div class="logo"> <%= image_tag attachments['mealnut.png'].url, :alt => 'Mealnut', :class => 'photo' %> </div> ``` But it is giving error: ``` undefined method `url' for nil:NilClass ``` Whats going wrong?

Original source