New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not respecting Relative Root URL #42
Comments
After a bit of digging around, I have found the issue. The issue is in Rails, specifically Sprockets::Helpers::RailsHelper::AssetPaths#compute_public_path. Sprockets::Helpers::RailsHelper::AssetPaths inherits from ActionView::AssetPaths and overrides a number of methods. When compute_public_path is called through the Sass::Rails::Resolver#public_path method is sass-rails, the rails sprocket helper picks up the task of resolving the asset. Sprockets::Helpers::RailsHelper::AssetPaths#compute_public_path defers to super which is ActionView::AssetPaths#compute_public_path. In this method there is a condition of has_request? on rewrite_relative_url_root as seen below:
If you look at the internals of rewrite_relative_url_root it relies on a request to be present and the ability to derive it from the controller variable in order to resolve the relative url root. The issue is that when sprockets resolves these assets for sass it does not have a controller present and therefore no request. Here is the solution that I am using to make it work for now:
|
Can you test with rails/rails#2977 ? |
sass-rails delegates url computation to rails. If not fixed there yet, please open a new issue against rails. |
…prockets. Fix #2435 See rails/sass-rails#42 for details
I'm running an application in a folder via Passenger, which I've configured via RackBaseURI. All the Rails routes and helpers respect this and correctly prepend the /folder to paths. Helpers in my sass files don't do this, and always start with /assets instead of /folder/assets.
Is there a configuration setting I'm missing somewhere?
image-url('layout/button_norm_states.png') produces url(/assets/layout/button_norm_states.png) instead of url(/folder/assets/layout/button_norm_states.png)
The text was updated successfully, but these errors were encountered: