This project is archived and is in readonly mode.
Add magic encoding comment to generated files
Reported by Craig Webster | March 21st, 2010 @ 08:16 PM
This patch allows you to set the way that asset paths are rewritten. My own use case was to accommodate a server setup where not all of the assets have the same mtime even if they're the same file.
If this is not set then it falls back to the default of using ENV['RAILS_ASSET_ID'] or the file mtime.
# config/environments/production.rb
# Normally you'd calculate RELEASE_NUMBER at startup.
RELEASE_NUMBER = 12345
config.action_controller.asset_path_template = proc { |asset_path|
"/release-#{RELEASE_NUMBER}#{asset_path}"
}
Comments and changes to this ticket
-
Craig Webster March 21st, 2010 @ 08:22 PM
- Title changed from Customising asset paths to [PATCH] Customising asset paths
Fixed a typo in the comments.
-
Stephan Wehner March 21st, 2010 @ 08:53 PM
Could you not override the rewrite_asset_path method? There is a comment at line 713 of http://github.com/rails/rails/blob/master/actionpack/lib/action_vie...
# Break out the asset path rewrite in case plugins wish to put the asset id # someplace other than the query string.
Stephan
-
Craig Webster March 21st, 2010 @ 09:08 PM
I could override it but rewrite_asset_path is private and not directly tested so it might go away in the future - possibly without notice. I feel that relying on this largely undocumented method existing in all version of Rails is a bad thing and that providing a tested, documented, public way of customising these paths is a better solution.
-
Stephan Wehner March 22nd, 2010 @ 03:35 AM
I see. That makes sense.
To me the comment describes what you're trying to accomplish, so maybe move it and the rewrite_asset_path method into the public section + add tests? Otherwise, I think the comment might as well be dropped.
Stephan
-
Craig Webster March 22nd, 2010 @ 08:49 AM
Exposing and testing rewrite_asset_path would be acceptable too, although the approach I've taken in the current patch does provide the same sort of API as setting asset_host and I prefer that.
I'll have a look into doing what you suggest tonight and see where I get. Thanks for your feedback!
-
Repository March 29th, 2010 @ 02:46 AM
- State changed from new to resolved
(from [201e8986b15f4d815355e0ca96e02cf16dba9372]) Updated asset_template_path to asset_path and have it also support a String [#4247 state:resolved] http://github.com/rails/rails/commit/201e8986b15f4d815355e0ca96e02c...
-
Ryan Bigg October 9th, 2010 @ 10:13 PM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 4247 [PATCH] Customising asset paths (from [201e8986b15f4d815355e0ca96e02cf16dba9372]) Updated...