title: What is wrong with my heroku asset:compilation?
body: <p>I am trying to insert an image into a mailer, everything runs locally but heroku doesn't see the image on its server despite pushing and precompiling as I'm ought to do. Code as below;</p>
  
  <p><em>user_mailer.rb</em></p>
  
  <pre><code>def welcome_email(user)
      @user = user
      attachments.inline['my_logo_sml.png'] = File.read('app/assets/images/my_logo_sml.png')
      mail(to: @user.email, subject: 'Welcome to Mybiz')
  end
  </code></pre>
  
  <p><em>welcome_email.html.erb</em></p>
  
  <pre><code>&lt;td class="six sub-columns header_logo"&gt;
      &lt;%= image_tag attachments["my_logo_sml.png"].url -%&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p><em>gemfile</em></p>
  
  <pre><code>gem 'rails_12factor', group: :production 
  </code></pre>
  
  <p><code>app/assets/images/my_logo_sml.png</code> is clearly present and getting through the pipline locally.</p>
  
  <p>I have run <code>RAILS_ENV=production bundle exec rake assets:precompile</code> a number of times, I have <code>heroku restart</code>'ed a number of times.</p>
  
  <p>Heroku logs:</p>
  
  <pre><code>2015-06-03T22:38:50.824191+00:00 app[web.1]: Errno::ENOENT (No such file or directory @ rb_sysopen - app/assets/images/my_logo_sml.png)
  </code></pre>
  
  <p>I'm at a loss after hours going round and around on this, can anyone help me please?</p>
  
  <p><strong>Update</strong></p>
  
  <p>After hours of looking at this i feel like it's not a syntax issue but an asset pre-compilation issue of some sort, I've copied my config/environments/production.rb code below if anyone can spot anything wrong?:</p>
  
  <pre><code>Rails.application.configure do
    config.cache_classes = true
    config.eager_load = true
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true
    config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
    config.assets.js_compressor = :uglifier
    config.assets.compile = true #concerned that this is the right thing to do?
    config.assets.digest = true
    config.log_level = :debug
    config.i18n.fallbacks = true
    config.active_support.deprecation = :notify
    config.log_formatter = ::Logger::Formatter.new
    config.active_record.dump_schema_after_migration = false
    config.action_mailer.asset_host = 'http://mysite.co'
    ActionMailer::Base.smtp_settings = {
      :address        =&gt; 'smtp.sendgrid.net',
      :port           =&gt; '587',
      :authentication =&gt; :plain,
      :user_name      =&gt; ENV['SENDGRID_USERNAME'],
      :password       =&gt; ENV['SENDGRID_PASSWORD'],
      :domain         =&gt; 'heroku.com',
      :enable_starttls_auto =&gt; true
    }
  end
  </code></pre>
  
  <p>Perhaps I could clean all compiled assets out and start the whole thing again, could anyone advise as to how to do this?</p>
  
  <p><strong>Update</strong></p>
  
  <p>The source of my problem seemed to be confusion between local and slug asset compilation. I ran <code>heroku run rake assets:clobber</code> and this solved all of my problems. Full understanding of what precisely was going on still eludes me, however running the above and having <code>config.assets.compile = true</code> in config/environments/production.rb has everything working just fine and upon <code>git push heroku</code> it shows me clearly that it's running both <code>rake assets:clean</code> and <code>rake assets:precompile</code> just fine. Syntax used in the view was:</p>
  
  <p><em>welcome_email.html.erb</em></p>
  
  <pre><code>&lt;%= image_tag('my_logo_sml.png', alt: "My Logo Small")%&gt;
  </code></pre>
  
  <p>I'm still unsure as to whether having <code>config.assets.compile = true</code> is the correct thing to do despite it seeming to solve the problem, i wonder whether it might end up compiling assets on multiple occasions?</p>