diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-07-03 03:57:31 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-07-03 03:57:31 +0000 |
commit | 66313f77ca20f563b824ca4d89d182aeaf30ea42 (patch) | |
tree | 6d179ec67013a8b20991fcd10ab67cb9b55b7187 | |
parent | 64b7c5fbd19323e02e0e3f58f6d4310d13b9a114 (diff) | |
download | rails-66313f77ca20f563b824ca4d89d182aeaf30ea42.tar.gz rails-66313f77ca20f563b824ca4d89d182aeaf30ea42.tar.bz2 rails-66313f77ca20f563b824ca4d89d182aeaf30ea42.zip |
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
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 |
2 files changed, 3 insertions, 1 deletions
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 @@ module ActiveRecord #:nodoc: # 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: |