Skip to content
This repository
Browse code

Rename image_path path_to_image to avoid conflicting with named route…

…s. Closes #9924 [gbuesing]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7970 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit b1c3fc22c9496d29685b37f0fb2c2df10bdd927a 1 parent 2fac5d1
Michael Koziarski authored October 19, 2007
3  actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -326,6 +326,7 @@ def stylesheet_link_tag(*sources)
326 326
       def image_path(source)
327 327
         compute_public_path(source, 'images')
328 328
       end
  329
+      alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
329 330
 
330 331
       # Returns an html image tag for the +source+. The +source+ can be a full
331 332
       # path or a file that exists in your public images directory.
@@ -356,7 +357,7 @@ def image_path(source)
356 357
       def image_tag(source, options = {})
357 358
         options.symbolize_keys!
358 359
 
359  
-        options[:src] = image_path(source)
  360
+        options[:src] = path_to_image(source)
360 361
         options[:alt] ||= File.basename(options[:src], '.*').split('.').first.capitalize
361 362
 
362 363
         if options[:size]
2  actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -361,7 +361,7 @@ def submit_tag(value = "Save changes", options = {})
361 361
       #   image_submit_tag("agree.png"), :disabled => true, :class => "agree-disagree-button"
362 362
       #   # => <input class="agree-disagree-button" disabled="disabled" src="/images/agree.png" type="image" />
363 363
       def image_submit_tag(source, options = {})
364  
-        tag :input, { "type" => "image", "src" => image_path(source) }.update(options.stringify_keys)
  364
+        tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys)
365 365
       end
366 366
 
367 367
       # Creates a field set for grouping HTML form elements.
4  actionpack/test/template/asset_tag_helper_test.rb
@@ -158,6 +158,10 @@ def test_image_path
158 158
     ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
159 159
   end
160 160
   
  161
+  def test_path_to_image_alias_for_image_path
  162
+    ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
  163
+  end
  164
+
161 165
   def test_image_tag
162 166
     ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
163 167
   end

0 notes on commit b1c3fc2

Please sign in to comment.
Something went wrong with that request. Please try again.