Rename image_path path_to_image to avoid conflicting with named routes. Closes #9924 [gbuesing]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7970 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
2fac5d1a8b
commit
b1c3fc22c9
@ -326,6 +326,7 @@ def stylesheet_link_tag(*sources)
|
||||
def image_path(source)
|
||||
compute_public_path(source, 'images')
|
||||
end
|
||||
alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
|
||||
|
||||
# Returns an html image tag for the +source+. The +source+ can be a full
|
||||
# path or a file that exists in your public images directory.
|
||||
@ -356,7 +357,7 @@ def image_path(source)
|
||||
def image_tag(source, options = {})
|
||||
options.symbolize_keys!
|
||||
|
||||
options[:src] = image_path(source)
|
||||
options[:src] = path_to_image(source)
|
||||
options[:alt] ||= File.basename(options[:src], '.*').split('.').first.capitalize
|
||||
|
||||
if options[:size]
|
||||
|
@ -361,7 +361,7 @@ def submit_tag(value = "Save changes", options = {})
|
||||
# image_submit_tag("agree.png"), :disabled => true, :class => "agree-disagree-button"
|
||||
# # => <input class="agree-disagree-button" disabled="disabled" src="/images/agree.png" type="image" />
|
||||
def image_submit_tag(source, options = {})
|
||||
tag :input, { "type" => "image", "src" => image_path(source) }.update(options.stringify_keys)
|
||||
tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys)
|
||||
end
|
||||
|
||||
# Creates a field set for grouping HTML form elements.
|
||||
|
@ -158,6 +158,10 @@ def test_image_path
|
||||
ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
||||
end
|
||||
|
||||
def test_path_to_image_alias_for_image_path
|
||||
ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
||||
end
|
||||
|
||||
def test_image_tag
|
||||
ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user