aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorDamien Mathieu <42@dmathieu.com>2011-06-26 09:41:30 +0200
committerDamien Mathieu <42@dmathieu.com>2011-06-26 09:41:30 +0200
commiteb22c51173f3ebe0f5a53f8bc57ebc74e4f0a824 (patch)
tree9e5c8a5ba8e3f93996a5db43bb613e1c2eb588b7 /activerecord/lib/active_record
parentbc743dc1ce4657be0c377edaab69f8e9ca0e350b (diff)
downloadrails-eb22c51173f3ebe0f5a53f8bc57ebc74e4f0a824.tar.gz
rails-eb22c51173f3ebe0f5a53f8bc57ebc74e4f0a824.tar.bz2
rails-eb22c51173f3ebe0f5a53f8bc57ebc74e4f0a824.zip
comparing different classes returns nil
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/base.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index a2b5a3ec4f..e970445082 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1806,7 +1806,11 @@ MSG
# Allows sort on objects
def <=>(other_object)
- self.to_key <=> other_object.to_key
+ if other_object.is_a?(self.class)
+ self.to_key <=> other_object.to_key
+ else
+ nil
+ end
end
# Backport dup from 1.9 so that initialize_dup() gets called