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
This commit is contained in:
Nicholas Seckar
2006-07-03 03:57:31 +00:00
parent 64b7c5fbd1
commit 66313f77ca
2 changed files with 3 additions and 1 deletions

View File

@@ -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]

View File

@@ -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: