0

I precompile my assets and use following function to render html:

= stylesheet_link_tag "frontend/application", media: "all", "data-turbolinks-track" => true
= javascript_include_tag "frontend/application", "data-turbolinks-track" => true

Sometimes those methods generat correct html:

<link data-turbolinks-track="true" href="/assets/frontend/application-64cf06dd4d2386f145e00844fed60d28.css" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/frontend/application-447281961c979f73e944369c4b832fd8.js"></script>

But on production rails sometimes (50%!) generates assets html like this

<link data-turbolinks-track="true" href="/stylesheets/frontend/application.css" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/javascripts/frontend/application.js"></script>

I use heroku on production. Any idea what could be wrong or how can I fix this?

Below are my production settings.

  # Disable Rails's static asset server (Apache or nginx will already do this).
  config.serve_static_assets = true

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

  # Generate digests for assets URLs.
  config.assets.digest = true

  # Version of your assets, change this if you want to expire all your assets.
  config.assets.version = '2'

  # Specifies the header that your server uses for sending files.
  # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

Here is also preview of the problem: view-source:http://v5.megabon.com/en

knagode
  • 5,816
  • 5
  • 49
  • 65
  • two things: why are you using config.assets.version = 2? i usually use 1.0. The other thing i would change is the serve_static_assets = false – sissy Mar 06 '14 at 16:05
  • have you read this http://stackoverflow.com/questions/15354539/heroku-does-not-compile-files-under-assets-pipelines-in-rails-4 maybe it can help you – sissy Mar 07 '14 at 07:34
  • NOthing helped .. I had to leave compile options set to true for now – knagode Mar 11 '14 at 00:26
  • i'm sorry...strange things seem to happen :) just another question: how are you precompiling your assets? manually with rake or with some deploy tool like capistrano? maybe you could precompile on your local server your assets and then deploy everything (not a good solution but better than compiling in production env) – sissy Mar 11 '14 at 08:05
  • I am compiling on local site. Btw: I think you are the first female interacting with me on SO :D Is there a badge for this? ;) – knagode Mar 11 '14 at 16:52
  • 1
    yeah a pink badge :) you see strange things happen :D – sissy Mar 12 '14 at 07:26

1 Answers1

0

The only way to get it work on Heroku was to set compile to false

config.assets.compile = false 

And delete every precompiled file in public folder. That forces Heroku to recompile assets on every git push.

knagode
  • 5,816
  • 5
  • 49
  • 65