-
Notifications
You must be signed in to change notification settings - Fork 785
Use image_path instead of asset_path in readme #69
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
Conversation
What does |
Basically just prepends "/assets" if the file is found in |
So what stopped working in Rails 4.2? |
# Rails 4.1
asset_path "application.js" # => /application.js
asset_path "application", type: :javascript # => /javascripts/application.js
asset_path "application", type: :stylesheet # => /stylesheets/application.css
asset_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js # Rails 4.2
asset_path "application.js" # => /assets/application.js
asset_path "application", type: :javascript # => /assets/application.js
asset_path "application", type: :stylesheet # => /assets/application.css
asset_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js It apparently stopped prepending the "stylesheets/javascripts/images" directory. |
How does this affect image assets used for emoji? |
The emoji images are copied to I don't know what |
@josh @charliesome Do you know why this would have changed in Rails 4.2? We're discussing it here for documentation purposes only, but still. |
👍 |
@janko-m OK can you amend the commit to add an explanation to the commit message then? |
In Rails 4.2 `#asset_path` has changed. Prior to Rails 4.2, `#asset_path` would search all asset directories, and prepend the appropriate asset type directory name to the result: asset_path("emoji/unicode/<id>.png") #=> "/images/emoji/unicode/<id>.png" However, In Rails 4.2 `#asset_path` doesn't do that anymore, and assumes that you've specified the correct folder. Since Emoji images are copied to public/images/emoji/unicode, `#asset_path` would then generate the wrong URL path: asset_path("emoji/unicode/<id>.png") #=> "/emoji/unicode/<id>.png" Using `#image_path` fixes that, because that method looks specifically for images/ folder, so it will find the Emoji images.
Amended. |
Perfect, thanks bro |
Use image_path instead of asset_path in readme
Bro five ✋ |
In Rails 4.2 using
asset_path
doesn't work properly, becauseasset_path
I think doesn't do anything except detect cache URLs. Withimage_path
it works for me.