Report abuse


			
# allows for <%= link_to @person %> and <%= link_to [@company, @person] %>
# link text is the #to_s representation of the object, or if an array is passed, the last object in the array
# works nicely with Mislav Marohnić's ActiveRecord:::Base default#to_s: http://pastie.caboo.se/74412

module ActionView
  module Helpers
    module UrlHelper
      def link_to_with_dry_logic(name, options = {}, html_options = nil)
        options = name if options.blank?
        url = options.is_a?(String) ? options : self.url_for(options)
        name ||= url
        name = name.last if name.is_a?(Array)
        name = html_escape(name.to_s) if name.respond_to?(:new_record?)
        link_to_without_dry_logic(name, options, html_options)
      end

      alias_method_chain :link_to, :dry_logic
    end
  end
end