7

Looks like this is a common issue, so let me begin by saying I've done a lot of research already.

Following this thread, I ran

heroku labs:enable user-env-compile -a myapp

Then I made sure that assets precompile locally by running

RAILS_ENV=production bundle exec rake assets:precompile

They do.

I also followed this tip, setting

config.assets.initialize_on_precompile = false

in my config/production.rb and config/application.rb.

Also, following this issue, I've made sure I have the heroku gems installed:

gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'
gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'

Then I made sure I had bin in my path by following this heroku article.

Then I made sure I followed the "Getting Started with Rails 4.x.x" article on heroku.

I've also followed another answer to this question and placed the following in application.rb and production.rb

config.serve_static_assets = true

Here's the error I get when running git push heroku master:

   Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   rake aborted!
   could not connect to server: Connection refused
   Is the server running on host "127.0.0.1" and accepting
   TCP/IP connections on port 5432?

It seems like config.assets.initialize_on_precompile = false should've worked, because it seems like it's trying to load the production database during precompliation.

I've made all these changes and they've been pushed to master in git. Now what should I try?

Community
  • 1
  • 1
nickcoxdotme
  • 6,567
  • 9
  • 46
  • 72

1 Answers1

3

Well, sorry about this. I guess I hadn't pushed the effects of RAILS_ENV=production bundle exec rake assets:precompile. Hopefully this serves as a number of resources for this issue.

Edit

In order to do this, I ran RAILS_ENV=production bundle exec rake assets:precompile. Then I committed this with

git add -A
git commit -m "precompiled assets"
git push origin master
git push heroku master
Community
  • 1
  • 1
nickcoxdotme
  • 6,567
  • 9
  • 46
  • 72
  • 1
    There is no `initialize_on_precompile` in Rails 4 either – Ev Dolzhenko Jul 05 '13 at 13:23
  • Could you explain how did you fix "I guess I hadn't pushed the effects of RAILS_ENV=production bundle exec rake assets:precompile."?Preferably for a rails noob :) – Halil Özgür Feb 10 '14 at 11:18
  • 3
    @HalilÖzgür there are two answers. When you type `RAILS_ENV=production` you are telling rails to start using the production settings, same as on heroku, so if there is an error, you will be able to see it before you push. The other part to this is that when you compile assets locally, you get a `public/assets/manifest` file generated. If heroku sees this, they won't run `rake assets:precompile` that's why he is adding them to his git repo, so heroku sees the manifest file. – mraaroncruz Sep 16 '14 at 15:37