Skip to content
This repository
Browse code

image_path -> path_to_image in a couple of places, plus motivation fo…

…r path_to_image in rdoc
  • Loading branch information...
commit 8b2266a8dada979d72ff6eda4349a24be3b630eb 1 parent 38f1d35
Xavier Noria authored
23  actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -515,7 +515,7 @@ def stylesheet_link_tag(*sources)
515 515
       #
516 516
       #   <%= favicon_link_tag 'favicon.ico' %>
517 517
       #
518  
-      # That's passed to +image_path+ as is, so it gives
  518
+      # That's passed to +path_to_image+ as is, so it gives
519 519
       #
520 520
       #   <link href="/images/favicon.ico?4649789979" rel="shortcut icon" type="image/vnd.microsoft.icon" />
521 521
       #
@@ -531,20 +531,23 @@ def favicon_link_tag(source='/favicon.ico', options={})
531 531
         tag('link', {
532 532
           :rel  => 'shortcut icon',
533 533
           :type => 'image/vnd.microsoft.icon',
534  
-          :href => image_path(source)
  534
+          :href => path_to_image(source)
535 535
         }.merge(options.symbolize_keys))
536 536
       end
537 537
 
538 538
       # Computes the path to an image asset in the public images directory.
539 539
       # Full paths from the document root will be passed through.
540  
-      # Used internally by +image_tag+ to build the image path.
  540
+      # Used internally by +image_tag+ to build the image path:
541 541
       #
542  
-      # ==== Examples
543  
-      #   image_path("edit")                                         # => /images/edit
544  
-      #   image_path("edit.png")                                     # => /images/edit.png
545  
-      #   image_path("icons/edit.png")                               # => /images/icons/edit.png
546  
-      #   image_path("/icons/edit.png")                              # => /icons/edit.png
547  
-      #   image_path("http://www.railsapplication.com/img/edit.png") # => http://www.railsapplication.com/img/edit.png
  542
+      #   image_path("edit")                                         # => "/images/edit"
  543
+      #   image_path("edit.png")                                     # => "/images/edit.png"
  544
+      #   image_path("icons/edit.png")                               # => "/images/icons/edit.png"
  545
+      #   image_path("/icons/edit.png")                              # => "/icons/edit.png"
  546
+      #   image_path("http://www.railsapplication.com/img/edit.png") # => "http://www.railsapplication.com/img/edit.png"
  547
+      #
  548
+      # If you have images as application resources this method may conflict with their named routes.
  549
+      # The alias +path_to_image+ is provided to avoid that. Rails uses the alias internally, and
  550
+      # plugin authors are encouraged to do so.
548 551
       def image_path(source)
549 552
         compute_public_path(source, 'images')
550 553
       end
@@ -624,7 +627,7 @@ def image_tag(source, options = {})
624 627
         end
625 628
 
626 629
         if mouseover = options.delete(:mouseover)
627  
-          options[:onmouseover] = "this.src='#{image_path(mouseover)}'"
  630
+          options[:onmouseover] = "this.src='#{path_to_image(mouseover)}'"
628 631
           options[:onmouseout]  = "this.src='#{src}'"
629 632
         end
630 633
 
2  actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -398,7 +398,7 @@ def submit_tag(value = "Save changes", options = {})
398 398
 
399 399
       # Displays an image which when clicked will submit the form.
400 400
       #
401  
-      # <tt>source</tt> is passed to AssetTagHelper#image_path
  401
+      # <tt>source</tt> is passed to AssetTagHelper#path_to_image
402 402
       #
403 403
       # ==== Options
404 404
       # * <tt>:confirm => 'question?'</tt> - This will add a JavaScript confirm

0 notes on commit 8b2266a

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