Skip to content

Commit 68364df

Browse files
committed
Squash merge apply/allow-specification-of-polymorphic-deps into release-4.1.1
1 parent 146af8c commit 68364df

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/ransack/search.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def build(params)
5252
add_scope(key, value)
5353
elsif base.attribute_method?(key)
5454
base.send("#{key}=", value)
55+
elsif 'pd' == key
56+
Array(value).each { |pd| add_polymorphic_dependency(pd) }
5557
elsif !Ransack.options[:ignore_unknown_conditions] || !@ignore_unknown_conditions
5658
raise ArgumentError, "Invalid search term #{key}"
5759
end
@@ -130,6 +132,12 @@ def inspect
130132

131133
private
132134

135+
def add_polymorphic_dependency(name)
136+
Ransack::Nodes::Attribute.new(context, name).tap do |a|
137+
context.bind(a, a.name)
138+
end
139+
end
140+
133141
def add_scope(key, args)
134142
sanitized_args = if Ransack.options[:sanitize_scope_args] && !@context.ransackable_scope_skip_sanitize_args?(key, @context.object)
135143
sanitized_scope_args(args)

0 commit comments

Comments
 (0)