Skip to content

Commit 82bb008

Browse files
committed
Associations do not call .to_proc on Hash
Fixes rails#25010
1 parent f85bbed commit 82bb008

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

activerecord/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
* Support Ruby 2.3 by not unexpectedly calling `.to_proc` on Hash objects
2+
3+
Fixes #25010
4+
5+
*tlrdstd*
6+
17
## Rails 3.2.22 (Jun 16, 2015) ##
28

39
* No changes.

activerecord/lib/active_record/associations/association.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def load_target
158158
end
159159

160160
def interpolate(sql, record = nil)
161-
if sql.respond_to?(:to_proc)
161+
if sql.respond_to?(:to_proc) && !sql.is_a?(Hash)
162162
owner.send(:instance_exec, record, &sql)
163163
else
164164
sql

activerecord/lib/active_record/associations/join_dependency/join_association.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def conditions
146146
private
147147

148148
def interpolate(conditions)
149-
if conditions.respond_to?(:to_proc)
149+
if conditions.respond_to?(:to_proc) && !conditions.is_a?(Hash)
150150
instance_eval(&conditions)
151151
else
152152
conditions

activerecord/lib/active_record/associations/preloader/association.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def build_scope
113113
end
114114

115115
def process_conditions(conditions)
116-
if conditions.respond_to?(:to_proc)
116+
if conditions.respond_to?(:to_proc) && !conditions.is_a?(Hash)
117117
conditions = klass.send(:instance_eval, &conditions)
118118
end
119119

0 commit comments

Comments
 (0)