From 1835aba6f176950b3d5532895f90b8a92a23f476 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 8 Jul 2011 12:45:32 +1000 Subject: Add section about debugging assets --- railties/guides/source/asset_pipeline.textile | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 9ad35b842f..563c1c79ae 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -90,7 +90,6 @@ When a scaffold or controller is generated for the application, Rails will also For example, if a +ProjectsController+ is generated, there will be a new file at +app/assets/javascripts/projects.js.coffee+ and another at +app/assets/stylesheets/projects.css.scss+. You should put any JavaScript or CSS unique to a controller inside their respective asset files, as these files can then be loaded just for these controllers with lines such as +<%= javascript_include_tag params[:controller] %>+ or +<%= stylesheet_link_tag params[:controller] %>+. - h4. Asset Organization Assets can be placed inside an application in one of three locations: +app/assets+, +lib/assets+ or +vendor/assets+. @@ -184,6 +183,31 @@ In the development environment assets are compiled and cached on the first reque If any of the files in the manifest have changed between requests, the server will respond with a new compiled file. +h4. Debugging Assets + +You can put +?debug_assets=true+ or +?debug_assets=1+ at the end of a URL and Sprockets will expand the lines which load the assets. For example, if we had an +app/assets/javascripts/application.js+ file containing these lines: + + +//= require "projects" +//= require "tickets" + + +By default, this would only render this line when used with +<%= javascript_include_tag "application" %>+ in a view or layout: + + + + + +When the +debug_assets+ parameter is set, this line will be expanded out into three separate lines, separating out the combined file into their parts. + + + + + + + +This allows the individual parts of an asset to be rendered and debugged separately. + h3. In Production In the production environment, assets are served slightly differently. -- cgit v1.2.3