Rails 4 resources still not precompiled in Heroku, despite setting rails_12factor gem

I recently tried updating the Rails 3.2.13 application to the recently released 4.0.0 and tried deploying it to Heroku. Unfortunately, despite the following this guide , assets still don't seem to be precompiling properly. Of course, I added gem rails_12factor , and I also did a few things to properly upgrade the application to 4.0.0. It works great in development mode, and all my tests still pass. However, it still does not display assets in Heroku.

One thing that I noticed when launching heroku run ls public/assets is that Heroku was really able to precompile the assets from app/assets , and the cat on these files will display the compiled version of the assets. However, if I access the file in the browser, I always get 404.

Is Heroku Really Ready for Rails 4?

EDIT

Here is a list of things I did to upgrade from 3.2.13 to 4:

  • Asset group removed because it is no longer used in Rails 4

  • Update rails version from 3.2.13 to 4.0.0

  • Remove the line active_resource/railties from the .rb application since active_resource was removed as a rails dependency

  • Update sass-rails and coffee-rails to use their respective leading branches because they use railties 4.0.0.rc2 instead of 4.0.0 as a dependency

  • Update devise version to 3.0.0.rc

  • Add protected_attributes to ease the transition to Rails 4 without having to switch to strong_parameters yet

  • Change your environment configuration to add config.eagerload and remove config.whiny_nils to remove the failure warnings.

  • Change the confirmation syntax () to remove the failure warnings.

  • Change hash syntax of hash missiles to syntax 1.9.3

  • Delete auto explanations configuration to remove failure warnings

  • Add bin directory with rake rails: update: bin

  • Add rails_12factor gem to be able to place the hero

  • Add ruby ​​version to gemfile for heroku

EDIT 2

I think it’s also worth mentioning that during the preliminary compilation in Heroku there were no errors, and in fact he says that he was successful in precompiling the assets, so it’s strange that this did not work.

+8
ruby-on-rails ruby-on-rails-4 heroku asset-pipeline
source share
4 answers

Try moving all the gems from the assets group in the Gemfile to the main area. The asset group is no longer used in Rails 4, and this can cause problems.

+1
source share

Using the version for less worked for me

 gem 'twitter-bootstrap-rails', '= 2.2.6' gem 'less-rails', '2.3.3' 
0
source share

I am facing the same problem. Now I precompile them locally

 bundle exec rake assets:precompile RAILS_ENV=production 

and add them to the vault and click on the hero.

0
source share

In the production.rb file, make sure you have the line config.assets.compile = true . This solved the problem for me.

-2
source share

All Articles