diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 14:59:48 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 14:59:48 -0700 |
commit | 2eecc0d8dccf7f12518e05a72192eb853e5ee474 (patch) | |
tree | de76f75c8910d0eafcd1f80e209e0314243b5edb /activerecord/lib | |
parent | 677b64fcd527529390e232ceedf8fa8bfac224e2 (diff) | |
download | rails-2eecc0d8dccf7f12518e05a72192eb853e5ee474.tar.gz rails-2eecc0d8dccf7f12518e05a72192eb853e5ee474.tar.bz2 rails-2eecc0d8dccf7f12518e05a72192eb853e5ee474.zip |
include bind values from the default scope
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index ae3fa85da9..94ab465cc1 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -489,11 +489,13 @@ module ActiveRecord # User.where(name: 'Oscar').where_values_hash # # => {name: "Oscar"} def where_values_hash - equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node| + scope = with_default_scope + equalities = scope.where_values.grep(Arel::Nodes::Equality).find_all { |node| node.left.relation.name == table_name } - binds = Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }] + binds = Hash[scope.bind_values.find_all(&:first).map { |column, v| [column.name, v] }] + binds.merge!(Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }]) Hash[equalities.map { |where| name = where.left.name |