I just get acquainted with Rails 3.1, and I burned for a while, updating an old project and trying to understand how the new asset pipeline in development mode behaves compared to production.
The default config.assets.precompile means only application.css and application.js , with the intention that everything should be used as one stylesheet and one javascript file.
Obviously, there are situations when we do not want this, so we can add items to the list in this configuration variable ...
Here is the situation that I encountered with my sandbox project when I went into production:
- I looked at the site in development, saw that everything was working. Assets were linked as separate files, and the site displayed correctly.
- I uploaded the site to my server and tried to make it work in production. The first error was that "ie.css" (conditional stylesheet) is not precompiled. (I was in Safari, and this stylesheet was not even loaded: the error was raised with the
stylesheet_link_tag helper before the page was displayed.) - Ran
rake assets:precompile and tried again. - Added an offensive element to
config.assets.precompile and tried again. - The error is corrupted until another asset fails.
- GOTO 3.
Not knowing how to solve this, I went around in circles several times until I thought that I had all the assets and the site was rendering in production. Then I tried it in MSIE and hit another 500 error: "belated_png_fix.js" was conditionally loaded, and until then it had not been displayed.
So my question is: besides trial and error or a strong dependence on integration testing, how can I predict that my site is not going to bomb when the asset pipeline detects that some stylesheets or javascript have not been added to the precompilation list?
I am also wondering why the missing element in the stylesheet should cause the whole page to be a 500 error, and not just compile it on request or serve 404 when this asset is requested. Is this a deliberate design "sooner or later"?
Andrew Vit
source share