0

I am having a problem with microposts rendering correctly on heroku, but not on localhost. I am following Hartl's Rails Tutorial guide.

Here is an imgur album showing the issue. The first image is the error(heroku), the second one is correct (localhost). https://i.stack.imgur.com/EssfS.png

I cannot for the life of me figure out why this would happen. It almost seems like Heroku is ignoring my CSS.

Here is the github repo: https://github.com/Mciocca/sample_app

Michael
  • 870
  • 3
  • 11
  • 18
  • Are the ends of tags being stripped? Doesn't look like a CSS issue. – anpsmn Apr 20 '13 at 22:14
  • How can I check for this? I have noticed using chrome dev tools that my microposts class isn't being used, even though I have set correctly in the html file. – Michael Apr 20 '13 at 23:31

2 Answers2

2

Sounds like one out of three possible reasons:

  1. There's a conflicting stylesheet interfering. Check out app/assets/stylesheets whether there are classes defined twice.
  2. Stack. I see you've placed pg in production in your gemfile, which is good. Heroku runs on Cedar stack - make sure it is. (Creating severe-mountain-793... done, **stack is cedar**)
  3. Not assuming anything, but I've been there several times: make sure you've included recent changes to your repo before pushing to heroku. git add . and git commit -am "brainfart", then git push heroku master <branch>.

And congrats on choosing Rails!

trymv
  • 175
  • 1
  • 14
  • Thanks for the suggestions. I checked to make sure there was nothing conflicting, ensured it was running on cedar, and even made a minor change so I could push it to heroku again. Still no luck =/ – Michael Apr 20 '13 at 23:33
  • It doesn't look like a problem, but try removing the .gitignore file and do `add .` and commit. (**ONLY DO THIS IF THERE'S NO CONFIDENTIAL INFORMATION IN THE DATABASE OR OTHER IGNORED FILES**) – trymv Apr 20 '13 at 23:46
  • I got it to work by enabling precompiling in the config file. Not exactly sure why this caused an issue, but it fixed it. Thanks for your help! – Michael Apr 20 '13 at 23:57
  • D'oh, should'ave seen that. Congrats, though, the reason can be read [here](https://devcenter.heroku.com/articles/rails-asset-pipeline) – trymv Apr 21 '13 at 00:04
  • 2
    This is also worth a look, it explains how to modify the config for production. http://stackoverflow.com/questions/7464544/ruby-on-rails-rake-assetsprecompile-error After you do the rake etc. make sure you push to heroku again. – Will Johnston Apr 26 '13 at 19:48
2

Run bundle exec rake assets:precompile to compile the assets incl. the stylesheets into the public hierarchy that is being used by Heroku.

When done:

git add -A

git commit -m "Precompiled assets" and finally

git push and git push heroku

For better understanding check out the Rails Guides on asset pipelines and the Heroku Guides on assest pipelines.