Use image_path instead of asset_path in readme
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.
This commit is contained in:
@@ -57,7 +57,7 @@ module EmojiHelper
|
||||
def emojify(content)
|
||||
h(content).to_str.gsub(/:([\w+-]+):/) do |match|
|
||||
if emoji = Emoji.find_by_alias($1)
|
||||
%(<img alt="#$1" src="#{asset_path("emoji/#{emoji.image_filename}")}" style="vertical-align:middle" width="20" height="20" />)
|
||||
%(<img alt="#$1" src="#{image_path("emoji/#{emoji.image_filename}")}" style="vertical-align:middle" width="20" height="20" />)
|
||||
else
|
||||
match
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ class DocumentationTest < TestCase
|
||||
str.gsub('<', '<').gsub('>', '>')
|
||||
end
|
||||
|
||||
def self.asset_path(img)
|
||||
def self.image_path(img)
|
||||
"/images/#{img}?123"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user