Created
October 23, 2009 11:58
-
-
Save nickcoyne/216833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def link_to( *args, &block ) | |
title_object = args.first if args.first.is_a?( ActiveRecord::Base ) | |
if title_object && ( args.size == 1 || ( args.size == 2 and args.last.is_a?(Hash) ) ) | |
args.insert( 1, polymorphic_url( title_object ) ) | |
end | |
options = args.get_or_initialize_options! | |
title_object ||= args.second if Rails.env != 'test' && args.second.is_a?( ActiveRecord::Base ) | |
if !options[:title].blank? | |
options[:title] = options[:title].to_s | |
elsif title_object | |
options[:title] = title_object.to_s | |
end | |
super | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment