From 8a9e031bcea772a5a9608fa17db824651138f352 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 9 May 2012 01:41:22 +0530 Subject: update some examples in asset tag helper docs [ci skip] --- .../lib/action_view/helpers/asset_tag_helper.rb | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 7985683a72..adc62ec6a9 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -13,15 +13,16 @@ module ActionView # the assets exist before linking to them: # # image_tag("rails.png") - # # => Rails + # # => Rails # stylesheet_link_tag("application") - # # => + # # => + # # # === Using asset hosts # # By default, Rails links to these assets on the current host in the public # folder, but you can direct Rails to link to assets from a dedicated asset - # server by setting ActionController::Base.asset_host in the application + # server by setting ActionController::Base.asset_host in the application # configuration, typically in config/environments/production.rb. # For example, you'd define assets.example.com to be your asset # host this way, inside the configure block of your environment-specific @@ -32,9 +33,9 @@ module ActionView # Helpers take that into account: # # image_tag("rails.png") - # # => Rails + # # => Rails # stylesheet_link_tag("application") - # # => + # # => # # Browsers typically open at most two simultaneous connections to a single # host, which means your assets often have to wait for other assets to finish @@ -45,9 +46,9 @@ module ActionView # will open eight simultaneous connections rather than two. # # image_tag("rails.png") - # # => Rails + # # => Rails # stylesheet_link_tag("application") - # # => + # # => # # To do this, you can either setup four actual hosts, or you can use wildcard # DNS to CNAME the wildcard to a single asset host. You can read more about @@ -64,29 +65,28 @@ module ActionView # "http://assets#{Digest::MD5.hexdigest(source).to_i(16) % 2 + 1}.example.com" # } # image_tag("rails.png") - # # => Rails + # # => Rails # stylesheet_link_tag("application") - # # => + # # => # # The example above generates "http://assets1.example.com" and # "http://assets2.example.com". This option is useful for example if # you need fewer/more than four hosts, custom host names, etc. # # As you see the proc takes a +source+ parameter. That's a string with the - # absolute path of the asset with any extensions and timestamps in place, - # for example "/images/rails.png?1230601161". + # absolute path of the asset, for example "/assets/rails.png". # # ActionController::Base.asset_host = Proc.new { |source| - # if source.starts_with?('/images') - # "http://images.example.com" + # if source.ends_with?('.css') + # "http://stylesheets.example.com" # else # "http://assets.example.com" # end # } # image_tag("rails.png") - # # => Rails + # # => Rails # stylesheet_link_tag("application") - # # => + # # => # # Alternatively you may ask for a second parameter +request+. That one is # particularly useful for serving assets from an SSL-protected page. The -- cgit v1.2.3