aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2011-07-08 12:45:32 +1000
committerRyan Bigg <radarlistener@gmail.com>2011-07-09 10:54:08 +1000
commit1835aba6f176950b3d5532895f90b8a92a23f476 (patch)
tree70dbd15c0ddeb7fd15df7811fd76fc7eb22a6ec4 /railties
parent678dd6f5d6f7ceb92146382c252d0902ab95a226 (diff)
downloadrails-1835aba6f176950b3d5532895f90b8a92a23f476.tar.gz
rails-1835aba6f176950b3d5532895f90b8a92a23f476.tar.bz2
rails-1835aba6f176950b3d5532895f90b8a92a23f476.zip
Add section about debugging assets
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/asset_pipeline.textile26
1 files changed, 25 insertions, 1 deletions
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:
+
+<plain>
+//= require "projects"
+//= require "tickets"
+</plain>
+
+By default, this would only render this line when used with +<%= javascript_include_tag "application" %>+ in a view or layout:
+
+<html>
+ <script src='/assets/application.js'></script>
+</html>
+
+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.
+
+<html>
+ <script src='/assets/application.js'></script>
+ <script src='/assets/projects.js'></script>
+ <script src='/assets/tickets.js'></script>
+</html>
+
+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.