searchable: fix searching for polymorphic attributes.
Fix not being able to use the full set of search operators on polymorphic `model_id` and `model_type` attributes. Before things like `search[model_type]=Post` worked, but `search[model_type_not_eq]=Post` or other `model_type_*` operators didn't.
This commit is contained in:
@@ -648,13 +648,8 @@ module Searchable
|
||||
relation = visible(relation, attr).where(attr => model.visible(current_user).search(params[model_key], current_user))
|
||||
end
|
||||
|
||||
if params["#{attr}_id"].present?
|
||||
relation = search_context(relation).search_attribute("#{attr}_id")
|
||||
end
|
||||
|
||||
if params["#{attr}_type"].present? && !model_specified
|
||||
relation = search_context(relation).search_attribute("#{attr}_type")
|
||||
end
|
||||
relation = search_context(relation).search_attribute("#{attr}_id")
|
||||
relation = search_context(relation).search_attribute("#{attr}_type")
|
||||
|
||||
relation
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user