1

My assets are not being properly precompiled to my staging heroku app. I usually use rake assets:precompile before pushing but my senior developer told me not to use that and put /public/assets into gitignore saying that heroku will automatically precompile the assets. When I push, heroku says that it runs rake assets:precompile but none of my assets show up. The page is just html.

possible causes: before my senior developer told me his way, I ran rake assets:precompile and removed /public/assets from gitignore as I though it wasn't suppose to be there. But after he told me, I put /public/assets back into .gitignore and deleted all the public assets and the assets still are not working on the heroku staging app. What am I missing?

Debadatt
  • 5,935
  • 4
  • 27
  • 40
monty_lennie
  • 2,871
  • 2
  • 29
  • 49

2 Answers2

2

I found the solution here: https://stackoverflow.com/a/16571492/1890135

I didn't specify this in the question but I was making a 2nd staging app not called staging so I had to add the rails_12factor gem under this new staging name environment.

group :staging_new, :staging, :production do
  gem 'rails_12factor' # To enable features such as static asset serving and logging on Heroku
end
Community
  • 1
  • 1
monty_lennie
  • 2,871
  • 2
  • 29
  • 49
1

Why did you include public/assets in your gitignore file anyway? There's no need for it to be in there, unless you've precompiled your assets locally & don't want to use them in Heroku?

--

A good way to test whether your app will work in staging is to run rake assets:precompile RAILS_ENV=production. This will do as Heroku would -- compiling your assets

What I would do initially is:

  • Precompile your assets locally (using rake assets:precompile RAILS_ENV=production)
  • Check in your public/assets folder for the precompiled files
  • If they're there, push to Heroku & do again
  • If not, there will be another problem to fix

Generally, though, Heroku's precompilation process is just the same as you would do locally. So maybe you could even try running your Rails server in production mode to see what the issue might be; it's probably more your app than Heroku

Richard Peck
  • 76,116
  • 9
  • 93
  • 147