ruby-on-railsherokuasset-pipelineprecompile

Rails 3.2 asset compilation issues on Heroku


It seems a lot of people are having similar problems. I consulted this thread, this, and this article, among others. I have found a lot of topics concerning these issues, but the posted solutions have been unable to find a definitive fix. I am currently running rails 3.2.8 with ruby 1.9.2, and Heroku stack cedar.

I am having two major, related issues:

1) My projects are pushing some assets - not all - to heroku.###

Per suggestions in other threads, when I place:

    config.assets.initialize_on_precompile = false

in my /config/application.rb,

    config.serve_static_assets = true
    config.assets.precompile += %w( *.js )

in /config/environments/production.rb, and

    gem 'rails_12factor', group: :production

in my gemfile, the push will precompile successfully, however the application.js file is empty on Heroku:

js issue1

2) Precompiling before a push successfully puts JS on Heroku, but it is no longer recognized.###

After removing

config.assets.precompile += %w( *.js )

from /config/production.rb, and running

RAILS_ENV=production bundle exec rake assets:precompile

committing and pushing results with index.html.erb not recognizing JS despite application.js present & non-empty as shown below:

js issue2

js issue3

I feel as if I have tried all combinations of these solutions to no avail. I have not yet updated the applications to Rails 4, is this a good idea to do at this time?

Any other suggestions where to go from here?

Oddly, in another Rails 3.2 app of mine, I get a similar error only the first time I visit###

Once the page loads, simply hitting refresh loads all content and the errors go away. This app has none of the attempted solutions above in its codebase.

other


Solution

  • I had the same problem, what solved it for me was specifying my ruby version in the gemfile.

    ruby '1.9.3'