diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-03 23:22:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-03 23:22:47 -0500 |
commit | a2b4df5b0bc2c1494665e07104cd2d8ceee08878 (patch) | |
tree | b1bfaba39ee039e5757d5843746007eec7819027 /activerecord/lib | |
parent | b9db45bb632853b709c64c736859e9ee347ca4bf (diff) | |
parent | b334aa0ea4008221c475adc5b124f3b23b785aba (diff) | |
download | rails-a2b4df5b0bc2c1494665e07104cd2d8ceee08878.tar.gz rails-a2b4df5b0bc2c1494665e07104cd2d8ceee08878.tar.bz2 rails-a2b4df5b0bc2c1494665e07104cd2d8ceee08878.zip |
Merge pull request #27564 from kamipo/fix_find_by_active_record_base_object-2
Fix `find_by` and `where` consistency
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 5d0f82130d..6d2361c4ac 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -196,12 +196,12 @@ module ActiveRecord end def find_by(*args) # :nodoc: - return super if scope_attributes? || !(Hash === args.first) || reflect_on_all_aggregations.any? + return super if scope_attributes? || reflect_on_all_aggregations.any? hash = args.first - return super if hash.values.any? { |v| - v.nil? || Array === v || Hash === v || Relation === v + return super if !(Hash === hash) || hash.values.any? { |v| + v.nil? || Array === v || Hash === v || Relation === v || Base === v } # We can't cache Post.find_by(author: david) ...yet |