diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 855192e18926b9972fdd4f120404bed4186c5164..2a1a23a4274e57c400f01f780a8204361668a14a 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Minor tweak to improve performance of ActiveRecord::Base#to_param. + * Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au] * Removed deprecated timestamps_gmt class methods. [Jeremy Kemper] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5aeb8eb3a1dd83871b61ec8bc6b0e43b59abab68..812f30c773b460744580c356f2535bf70879e50a 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1441,7 +1441,7 @@ def id # Enables Active Record objects to be used as URL parameters in Action Pack automatically. def to_param # We can't use alias_method here, because method 'id' optimizes itself on the fly. - id.to_s if id # Be sure to stringify the id for routes + (id = self.id) ? id.to_s : nil # Be sure to stringify the id for routes end def id_before_type_cast #:nodoc: