Support using all numeric searches for includes
This commit is contained in:
@@ -10,6 +10,10 @@ module Searchable
|
|||||||
1 + params.values.map { |v| parameter_hash?(v) ? parameter_depth(v) : 1 }.max
|
1 + params.values.map { |v| parameter_hash?(v) ? parameter_depth(v) : 1 }.max
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefix_matches(prefix, params)
|
||||||
|
params.keys.any? { |x| x.starts_with?(prefix) }
|
||||||
|
end
|
||||||
|
|
||||||
def negate_relation
|
def negate_relation
|
||||||
unscoped.where(all.where_clause.invert.ast)
|
unscoped.where(all.where_clause.invert.ast)
|
||||||
end
|
end
|
||||||
@@ -279,7 +283,7 @@ module Searchable
|
|||||||
|
|
||||||
def search_includes(attr, params, type, current_user)
|
def search_includes(attr, params, type, current_user)
|
||||||
model = Kernel.const_get(type)
|
model = Kernel.const_get(type)
|
||||||
if params["#{attr}_id"].present?
|
if prefix_matches("#{attr}_id", params)
|
||||||
search_attribute("#{attr}_id", params, current_user)
|
search_attribute("#{attr}_id", params, current_user)
|
||||||
elsif params["has_#{attr}"].to_s.truthy? || params["has_#{attr}"].to_s.falsy?
|
elsif params["has_#{attr}"].to_s.truthy? || params["has_#{attr}"].to_s.falsy?
|
||||||
search_has_include(attr, params["has_#{attr}"].to_s.truthy?, model)
|
search_has_include(attr, params["has_#{attr}"].to_s.truthy?, model)
|
||||||
|
|||||||
Reference in New Issue
Block a user