Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Stylesheets on Heroku

On my local machine, when I view my Rails App, my stylesheets are successfully linked at /assets/stylesheets/ but on Heroku, it is changed to /stylesheets/ presumably in the public directory and does not work! How do I get my stylesheets to move to public/stylesheets on compilation?

EDIT:

File directory after rake assets:precompile

app
  assets
    stylesheets
      application.css
      application.min.css
      home.css
      home.css.scss
      home.min.css
      scaffolds.css
      scaffolds.css.scss
      scaffolds.min.css
      startups.css
      startups.css.scss
public
  assets
    application-3701cb84bbc3c20d5a7ec1aac608fbdb.js
    application-3701cb84bbc3c20d5a7ec1aac608fbdb.js.gz
    application-f7ff7ad51f3528ccca1b5c7f2d5b5915.css
    application-f7ff7ad51f3528ccca1b5c7f2d5b5915.css.gz
    manifest-ad3babc6c84cc0b38f1a98eb594b8235.json
    rails-afd7b40a0142ed24738b640e78388de4.png

Here is my stylesheet link in application.html.haml:

stylesheet_link_tag "flat-ui", "home.min", media: "all"

gem flatui-rails is in my Gemfile and *= require flat-ui is in my application.css file.

EDIT 2:

Cleared my public/assets folder, added public/assets/* to my .gitignore and pushed to my Heroku repo. During slug compilation Heroku ran the asset pipline and made /assets/application-b2c82b0573602f3a368a26f36b99542b.css which is also linked in the source code of my site, but the styles don't load and I get The page you were looking for doesn't exist. when I try to navigate to the style sheet... Now what?

Here's my application.html.haml:

!!! 5
%html
  %head
    %title StartupCrawler
    = stylesheet_link_tag "application", media: "all"
    = csrf_meta_tags
  = yield
like image 695
Michael Johnston Avatar asked Apr 18 '13 03:04

Michael Johnston


1 Answers

Michael, I before you push to heroku try:

rake assets:precompile

This will precompile them in the public folder so that they can be served to Heroku. Let me know if that didn't work.

Also, make sure the following line exists in config/environments/production.rb

config.serve_static_assets = true

Then of course

git push heroku master

like image 54
Xaca Xulu Avatar answered Sep 28 '22 01:09

Xaca Xulu