diff options
author | Xavier Noria <fxn@hashref.com> | 2011-09-28 13:48:23 -0700 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-09-28 13:48:48 -0700 |
commit | cba3c00831a7c5bb25bc785e856984705ca2077c (patch) | |
tree | f9e4222eda3e0c52eeb7088131221f85b6884294 /railties | |
parent | f3b8cd9d364934795ee4ec63a2d8852b3dde1aa8 (diff) | |
download | rails-cba3c00831a7c5bb25bc785e856984705ca2077c.tar.gz rails-cba3c00831a7c5bb25bc785e856984705ca2077c.tar.bz2 rails-cba3c00831a7c5bb25bc785e856984705ca2077c.zip |
partial pass over the assets guide
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/asset_pipeline.textile | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 152f42f4eb..a0af018d30 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -261,7 +261,7 @@ h3. In Development In development mode assets are served as separate files in the order they are specified in the manifest file. -This manifest +application.js+: +This manifest +app/assets/javascripts/application.js+: <plain> //= require core @@ -272,45 +272,42 @@ This manifest +application.js+: would generate this HTML: <html> -<script src='/assets/core.js?body=1'></script> -<script src='/assets/projects.js?body=1'></script> -<script src='/assets/tickets.js?body=1'></script> +<script src="/assets/core.js?body=1" type="text/javascript"></script> +<script src="/assets/projects.js?body=1" type="text/javascript"></script> +<script src="/assets/tickets.js?body=1" type="text/javascript"></script> </html> The +body+ param is required by Sprockets. h4. Turning Debugging off -You can turn off debug mode by updating +development.rb+ to include: +You can turn off debug mode by updating +config/environments/development.rb+ to include: -<erb> +<ruby> config.assets.debug = false -</erb> +</ruby> -When debug mode is off Sprockets will concatenate and run the necessary preprocessors on all files, generating the following HTML: +When debug mode is off Sprockets concatenates and runs the necessary preprocessors on all files. With debug mode turned off the manifest above would generate instead: <html> -<script src='/assets/application.js'></script> +<script src="/assets/application.js" type="text/javascript"></script> </html> -Assets are compiled and cached on the first request after the server is started. Sprockets sets a +must-revalidate+ Cache-Control HTTP header to reduce request overhead on subsequent requests -- on these the browser gets a 304 (not-modified) response. +Assets are compiled and cached on the first request after the server is started. Sprockets sets a +must-revalidate+ Cache-Control HTTP header to reduce request overhead on subsequent requests -- on these the browser gets a 304 (Not Modified) response. If any of the files in the manifest have changed between requests, the server responds with a new compiled file. -You can put +?debug_assets=true+ or +?debug_assets=1+ at the end of a URL to enable debug mode on-demand, and this will render individual tags for each file. This is useful for tracking down exact line numbers when debugging. - -Debug can also be set in the Rails helper methods: +Debug mode can also be enabled in the Rails helper methods: <erb> <%= stylesheet_link_tag "application", :debug => true %> <%= javascript_include_tag "application", :debug => true %> </erb> -The +:debug+ option is ignored if the debug mode is off. +The +:debug+ option is redundant if debug mode is on. You could potentially also enable compression in development mode as a sanity check, and disable it on-demand as required for debugging. - h3. In Production In the production environment Rails uses the fingerprinting scheme outlined above. By default it is assumed that assets have been precompiled and will be served as static assets by your web server. |