Skip to content

Commit

Permalink
AR::Integration must be included after AM::Conversion
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jfirebaugh committed Jul 17, 2012
1 parent d8745de commit 80f6125
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def self.append_features(base)
include Inheritance
include Scoping
include Sanitization
include Integration
include AttributeAssignment
include ActiveModel::Conversion
include Integration
include Validations
include CounterCache
include Locking::Optimistic
Expand Down
6 changes: 6 additions & 0 deletions activerecord/test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,12 @@ def test_to_param_should_return_string
assert_kind_of String, Client.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
Expand Down

0 comments on commit 80f6125

Please sign in to comment.