This project is archived and is in readonly mode.
Allow absolute paths for the asset :cache option
Reported by Andrew Kaspick | June 5th, 2009 @ 05:01 AM | in 2.x
This patch allows using an absolute path with the :cache option for stylesheet_link_tag and javascript_include_tag which didn't work before...
stylesheet_link_tag(:all, :cache => "/absolute/test")
Relative paths are accepted such as...
stylesheet_link_tag(:all, :cache => "../relative/test")
so this patch makes things more consitent and allows both.
Comments and changes to this ticket
-
Michael Koziarski June 10th, 2009 @ 04:28 AM
Those aren't (strictly speaking) absolute paths though? They're still relative to the public directory?
Out of interest, what's the use case that you have in mind where storing it in public is ok but in public/javascripts isn't?
-
Andrew Kaspick June 10th, 2009 @ 04:56 AM
Absolute to the asset dir (public) that is, just as any path reference can be absolute with respect to the asset dir used with any of the current asset methods (image_tag, stylesheet_link_tag, javascript_tag)
image_tag '/otherimages/image.png' # "absolute" reference
The use case this came from is where I have bluetrip (css framework) installed in the base asset dir (public). Bluetrip refers to images in it's stylesheets relative to that stylesheets location, so it expects the css file to reside in a specific directory in order to for the image references to resolve correctly.
<%= stylesheet_link_tag '/bluetrip/css/screen', '/bluetrip/css/style' %>
When stylesheet_link_tag is used with the :cache option, that collapses all of these css files into one file in the public/stylesheets directory, so the images are no longer in the correct relative spot for this new cached css file.
.somerule { background-image: url(../resources/ok.png); }
This is how I currently fix the problem; by using a '../bluetrip/css/blueprint' "relative" path.
<%= stylesheet_link_tag '/bluetrip/css/screen', '/bluetrip/css/style', :cache => '../bluetrip/css/bluetrip' %>
With my patch I'd be able to change that to an "absolute" path, just like any other asset file reference.
<%= stylesheet_link_tag '/bluetrip/css/screen', '/bluetrip/css/style', :cache => '/bluetrip/css/blueprint' %>
It's a minor difference, but follows the same path naming rules that are used in the rest of the asset method. Also without this patch, the cached file is saved as 'public/stylesheets/bluetrip/css/blueprint.css', which is not correct for allowing the image references in the stylesheet to resolve.
If I'm not clear with my explanation, please let me know.
Thanks
-
Michael Koziarski June 10th, 2009 @ 09:50 AM
OK, Last thing is this patch doesn't clean up after itself right.
Run rake test a few times and then git status.
If you can fix that I'll apply it to master.
-
Andrew Kaspick June 10th, 2009 @ 05:05 PM
- no changes were found...
-
Michael Koziarski June 11th, 2009 @ 05:35 AM
- State changed from new to resolved
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>