diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2012-07-17 13:56:47 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2012-07-17 13:57:30 -0700 |
commit | 9b5309fb6819d8f2a1b31e44ba61e682272c7aa3 (patch) | |
tree | ad59ff48bfab0dd0b5144a1c4b478964887c9fe3 | |
parent | 71d274dbbb3972afb7808a84ecdd005d95107212 (diff) | |
download | rails-9b5309fb6819d8f2a1b31e44ba61e682272c7aa3.tar.gz rails-9b5309fb6819d8f2a1b31e44ba61e682272c7aa3.tar.bz2 rails-9b5309fb6819d8f2a1b31e44ba61e682272c7aa3.zip |
AR::Integration must be included after AM::Conversion
Integration's definition of #to_param must override
Conversion's. Otherwise, there is a regression from
3.1 in the behavior of a non-persisted AR::Base instance
which nevertheless has an id.
-rw-r--r-- | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c6f2102a5f..b51bb5cc5e 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -697,9 +697,9 @@ module ActiveRecord #:nodoc: include Scoping extend DynamicMatchers include Sanitization - include Integration include AttributeAssignment include ActiveModel::Conversion + include Integration include Validations extend CounterCache include Locking::Optimistic, Locking::Pessimistic diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 91a70e0239..db42f17eeb 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1911,6 +1911,12 @@ class BasicsTest < ActiveRecord::TestCase assert_kind_of String, Client.find(:first).to_param end + def test_to_param_returns_id_even_if_not_persisted + client = Client.new + client.id = 1 + assert_equal "1", client.to_param + end + def test_inspect_class assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect assert_equal 'LoosePerson(abstract)', LoosePerson.inspect |