7

I have stylesheet_link_tag(:all) in my layout.

It behaves as expected on local machine, even when I run it in production environment (rails s -e production).

By expected I mean that it emits all the links to existing stylesheets without concating them into all.css and it does not emit the link to all.css.

But when I deploy it to Heroku, the result is the same plus a link to all.css in the beginning. This is what I don't want and don't expect, especially when production environment on local machine does not emit it.

So the question is how do I get rid of all.css link on Heroku without specifying all files manually?

Thanks.

Dmytrii Nagirniak
  • 23,696
  • 13
  • 75
  • 130
  • 1
    You're not using `:cache => true`? – lebreeze Mar 30 '11 at 15:07
  • That's the problem, I don't. Only `stylesheet_link_tag(:all)` – Dmytrii Nagirniak Mar 30 '11 at 15:23
  • Could it be that you've got a file called all.css on the server and it's automatically linking to that? – Dominik Grabiec Mar 31 '11 at 03:44
  • I don't think so. The request to `all.css` fails with 404. Also my Git repo has no such file and thus could not be possibly deployed to Heroku. If it would be on the file system, then it would also appear on the local machine in all environments (which it doesn't). So I would say No, it can't be that there is such a file. – Dmytrii Nagirniak Mar 31 '11 at 04:57
  • I have just double checked from Heroku console: `File.exists? 'public/stylesheets/application.css' # => true` and `File.exists? 'public/stylesheets/all.css' # => false`. So definitely there is no such file on the file system. – Dmytrii Nagirniak Mar 31 '11 at 05:00
  • I had the same issue, heroku doesnt supports asset storage so this is the source of the problem. I ended up including each css individualy. – dombesz Mar 31 '11 at 08:31
  • @dombesz Just to be on the same page: What exactly do you mean by "asset storage"? – Dmytrii Nagirniak Apr 01 '11 at 03:25
  • 3
    @Dmytrii Nagirniak heroku doesnt allow you to upload, or create files from the code. Because their system stores your app in the cloud in different servers, and it's too costly to for them to allow you to create files. And if you do stylesheet_link_tag(:all) it generates an all.css on the fly and heroku doesnt support to store that file on their filesystem, and thats why you get errors. Maybe you can try to add the all.css to the repo and upload to heroku. Let me know if something is not clear. – dombesz Apr 01 '11 at 08:57
  • 1
    all.css is only generated with :cach=>true. I don't set it. – Dmytrii Nagirniak Apr 02 '11 at 00:55
  • @dombesz - your last comment is spot-on, you should post it as an answer. I almost missed it because it was hidden under the "fold" which shows the first four or five comments on a post. – Max Williams Jun 23 '11 at 14:42

1 Answers1

1

Heroku is doing some special handling of asset files, see for example: http://devcenter.heroku.com/articles/rails3 and Why does a rails app on heroku serve assets via all.css and locally via individual files especially the final comment about :cache => true working now and about File.open operations not working.

They aren't expecting your use case as the most common, so it is possible that there is some bug in their handling. I would try explicitly setting :cache => false and :config => false

Community
  • 1
  • 1
Ray Baxter
  • 3,181
  • 23
  • 27
  • I tried setting `:cache => false` and it has no any effect. I already said that in the comments to my question. The links you provided don't really explain anything, they don't explain WHY `all.css` is generated together with all other files (instead of a single one). Can't see anything in you answer that helps me to solve the issue :( – Dmytrii Nagirniak Apr 10 '11 at 23:59
  • You said in your comment that you weren't setting `:cache => true` which is a different thing than explicitly setting `:cache => false`. The links that I provided explain why `File.exists? 'public/stylesheets/all.css'` might return `false` even if a bug in Heroku's code is incorrectly assuming it exists in some code paths. – Ray Baxter Apr 12 '11 at 03:42
  • Ray, I tried to set `:cache => false` explicitly. Same thing. I also can't see where your links explain the situation with `File.exists?` Can you please point it to me? – Dmytrii Nagirniak Apr 26 '11 at 22:44
  • On [this page](http://stackoverflow.com/questions/5488090/stylesheet-link-tagall-generates-reference-to-all-css-on-heroku/5610329#5610329) August Lilleaas Jan 22 '10 at 21:07 says that using `:cache => true` generates an `all.css`, but that `File.open operations` are blocked. – Ray Baxter May 04 '11 at 03:47
  • My point was that your Mar 31 5:00 comment about `File.exists 'public/stylesheets/all.css'` returning `false` doesn't imply that Heroku isn't failing to respect your `:cache => false` and creating some virtual version of `all.css`. – Ray Baxter May 04 '11 at 03:53