Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
asset_path helper not including relative url when used in .css.erb #3365
I'm using Rails 3.1.1 and Passenger to deploy an application to
transforms into proper path:
But the same helper in my
I've seen a lot of older issues similar to this one, but none of them fixed this, so far. This basically renders
EDIT: Same thing applies when using
I've been having the same or similar problem since 3.1 was released. Resolution of relative url roots for assets using css/sass/scss/erb appears to be on-again-off-again. There are several similar threads about this issue. Some of them:
With Rails 3.1.0, I solved the problem with the Sass::Rails::Helpers#public_path fix, mentioned in the above links. But with Rails 3.1.1, this fix no longer appears effective.
For me, with a fresh install of Rails 3.1.1 and all of it's dependencies, "image-url" in a scss file ignores the ENV['RAILS_RELATIVE_URL_ROOT'] environment variable, even though all of my view helpers resolve it correctly. Interestingly, "asset-url" DOES work.
I'm having the same problem with
<%= asset_path('zurb-nub-shell-hover.png') %>
But as ginjo said,
I'm running Rails 3.1.3.
That's my impression, too. Would be great if this could be fixed for good. Plus, Stackoverflow is full of work-arounds which all appear to be outdated despite their young age.
Ok guys, I have some good news. I managed to fix the
With my fix (https://github.com/pokonski/rails/commit/53cebf7eb80d6b97c21c421cbc7d1f572170e33f) it now generates proper paths for assets in sub-uri.
For production you still need to set that ENV variable before precompiling assets, just do this:
RAILS_RELATIVE_URL_ROOT="/suburi" rake assets:precompile