Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4459

Show
Ignore:
Timestamp:
06/19/06 16:45:34 (2 years ago)
Author:
ulysses
Message:

Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r4437 r4459  
    11*SVN* 
     2 
     3* Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar] 
    24 
    35* Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de) 
  • trunk/activerecord/lib/active_record/base.rb

    r4437 r4459  
    14111411      # Enables Active Record objects to be used as URL parameters in Action Pack automatically. 
    14121412      def to_param 
    1413         # can't use alias_method here, because method 'id' optimizes itself on the fly 
    1414         id 
     1413        # We can't use alias_method here, because method 'id' optimizes itself on the fly. 
     1414        id.to_s if id # Be sure to stringify the id for routes 
    14151415      end 
    14161416 
  • trunk/activerecord/test/base_test.rb

    r4431 r4459  
    13171317    assert_equal '::Person', ActiveRecord::Base.send(:type_name_with_module, '::Person') 
    13181318  end 
     1319   
     1320  def test_to_param_should_return_string 
     1321    assert_kind_of String, Client.find(:first).to_param 
     1322  end 
    13191323 
    13201324  # FIXME: this test ought to run, but it needs to run sandboxed so that it