diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2013-11-02 19:56:58 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2013-11-02 19:56:58 -0700 |
commit | 430b252d3d9bcf12951c2c58b744e83d43a34223 (patch) | |
tree | 13e6d6039c02a833c3db188bff3d6c06d7e3f043 /activerecord/lib/active_record | |
parent | 661637e5b64dc1c277beb927059824ce4848ebab (diff) | |
download | rails-430b252d3d9bcf12951c2c58b744e83d43a34223.tar.gz rails-430b252d3d9bcf12951c2c58b744e83d43a34223.tar.bz2 rails-430b252d3d9bcf12951c2c58b744e83d43a34223.zip |
Revert "ActiveRecord::Base#<=> has been removed. Primary keys may not be in order," -- will be replaced with a check to ensure that the keys used for comparison are integers, and only fail if they are not.
This reverts commit 6256734e2d0bdd89f4b5d11da259d40afa0c95c7.
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 366ebde418..d9cb14e4c6 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -310,6 +310,15 @@ module ActiveRecord @attributes.frozen? end + # Allows sort on objects + def <=>(other_object) + if other_object.is_a?(self.class) + self.to_key <=> other_object.to_key + else + super + end + end + # Returns +true+ if the record is read only. Records loaded through joins with piggy-back # attributes will be marked as read only since they cannot be saved. def readonly? |