diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-03-29 04:27:23 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-03-29 04:34:20 -0700 |
commit | 945dd254ae4a79705c2c05a683fc37a8c98c8aeb (patch) | |
tree | cd99f279cdd67180122db5ba20851cb4e2b9ba7f /activerecord/lib/active_record | |
parent | 86c53d510cf31b792a7e96a44535e64b3983d17a (diff) | |
download | rails-945dd254ae4a79705c2c05a683fc37a8c98c8aeb.tar.gz rails-945dd254ae4a79705c2c05a683fc37a8c98c8aeb.tar.bz2 rails-945dd254ae4a79705c2c05a683fc37a8c98c8aeb.zip |
Ensure we are returning either `true` or `false` for `#==`
460eb83d cused `ActiveRecord::Base#==` to sometimes return `nil` in some cases,
this ensures we always return a boolean value. Also fixed a similar problem in
AR reflections.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index d9aaf8597f..4e53f66005 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -299,7 +299,7 @@ module ActiveRecord def ==(comparison_object) super || comparison_object.instance_of?(self.class) && - id && + !id.nil? && comparison_object.id == id end alias :eql? :== diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index bce7766501..03b5bdc46c 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -151,7 +151,7 @@ module ActiveRecord super || other_aggregation.kind_of?(self.class) && name == other_aggregation.name && - other_aggregation.options && + !other_aggregation.options.nil? && active_record == other_aggregation.active_record end |