aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-07-31 15:31:21 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-07-31 15:31:21 -0700
commit5e9f49aad94d11c19626c95189223aa88896ae22 (patch)
treef90ce2a850b88af8c43962e9090a44b6e76638fe /activerecord/lib/active_record/associations
parent742d1f2eda24dd411e018835680645d3921883f5 (diff)
downloadrails-5e9f49aad94d11c19626c95189223aa88896ae22.tar.gz
rails-5e9f49aad94d11c19626c95189223aa88896ae22.tar.bz2
rails-5e9f49aad94d11c19626c95189223aa88896ae22.zip
use bind values for model types
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/association_scope.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb
index 62b9c94422..8027acfb83 100644
--- a/activerecord/lib/active_record/associations/association_scope.rb
+++ b/activerecord/lib/active_record/associations/association_scope.rb
@@ -82,8 +82,9 @@ module ActiveRecord
constraint = table[key].eq(foreign_table[foreign_key])
if reflection.type
- type = chain[i + 1].klass.base_class.name
- constraint = constraint.and(table[reflection.type].eq(type))
+ value = chain[i + 1].klass.base_class.name
+ bind_val = bind scope, table.table_name, reflection.type.to_s, value
+ scope = scope.where(table[reflection.type].eq(bind_val))
end
scope = scope.joins(join(foreign_table, constraint))