Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 assets still don't precompile in Heroku despite installing the rails_12factor gem

I recently tried upgrading my Rails 3.2.13 app to the newly released 4.0.0 and tried deploying it to Heroku. Unfortunately, despite following this guide, the assets still don't seem to precompile properly. Of course, I added the rails_12factor gem already and I also did a couple of things to properly upgrade the app to 4.0.0. It works very nicely on development mode and all my tests are still passing. However, it still doesn't display the assets in Heroku.

One thing I noticed from running heroku run ls public/assets is that Heroku was actually able to precompile the assets from app/assets and doing a cat command on those files will display the compiled version of the assets. However, if I access the file on the browser, I always get a 404.

Is Heroku actually ready for Rails 4?

EDIT:

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

  • Removed asset group as it is no longer used in Rails 4

  • Update version of rails from 3.2.13 to 4.0.0

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

  • Update sass-rails and coffee-rails to use their corresponding master branches because it is using railties 4.0.0.rc2 instead of 4.0.0 as the dependency

  • Update version of devise to 3.0.0.rc

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

  • Change environment configs to add config.eagerload and remove config.whiny_nils to remove deprecation warnings.

  • Change syntax of confirm() to remove deprecation warnings

  • Change hash syntax from hash rockets to the 1.9.3 syntax

  • Remove auto explain config to remove deprecation warnings

  • Add bin directory using rake rails:update:bin

  • Add rails_12factor gem to be able to host to heroku

  • Add ruby version in Gemfile for heroku

EDIT 2

I guess it's also worth mentioning that there wasn't any errors in Heroku during the precompilation and it actually says that it was successful in precompiling the assets which is why it's strange that it didn't work.

like image 996
Terence Ponce Avatar asked Jul 04 '13 23:07

Terence Ponce


1 Answers

Try moving all gems from assets group in Gemfile to main scope. Assets group is no longer used in Rails 4 and that may be causing the problem.

like image 91
Mike Szyndel Avatar answered Nov 15 '22 07:11

Mike Szyndel