From 66313f77ca20f563b824ca4d89d182aeaf30ea42 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Mon, 3 Jul 2006 03:57:31 +0000 Subject: [PATCH] Minor tweak to improve performance of ActiveRecord::Base#to_param git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4531 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ activerecord/lib/active_record/base.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 855192e189..2a1a23a427 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 5aeb8eb3a1..812f30c773 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: -- GitLab