Skip to content

Commit

Permalink
Change AR::Base#to_param to return a String instead of a Fixnum. Closes
Browse files Browse the repository at this point in the history
#5320.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4459 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
seckar committed Jun 19, 2006
1 parent ae0e1a0 commit e5fc5aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar]

* Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de)

* Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [DHH]
Expand Down
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -1410,8 +1410,8 @@ def id

# Enables Active Record objects to be used as URL parameters in Action Pack automatically.
def to_param
# can't use alias_method here, because method 'id' optimizes itself on the fly
id
# 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
end

def id_before_type_cast #:nodoc:
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/base_test.rb
Expand Up @@ -1316,6 +1316,10 @@ def test_type_name_with_module_should_handle_beginning
assert_equal 'ActiveRecord::Person', ActiveRecord::Base.send(:type_name_with_module, 'Person')
assert_equal '::Person', ActiveRecord::Base.send(:type_name_with_module, '::Person')
end

def test_to_param_should_return_string
assert_kind_of String, Client.find(:first).to_param
end

# FIXME: this test ought to run, but it needs to run sandboxed so that it
# doesn't b0rk the current test environment by undefing everything.
Expand Down

0 comments on commit e5fc5aa

Please sign in to comment.