searchable: don't automatically include id, created_at, updated_at.

Don't make search methods on models call super in order to search
certain default attributes (id, created_at, updated_at). Simplifies some
magic.
This commit is contained in:
evazion
2020-12-16 22:00:22 -06:00
parent b0659eb76c
commit e771c0fca8
45 changed files with 51 additions and 121 deletions

View File

@@ -155,6 +155,7 @@ module Searchable
indifferent_params = params.try(:with_indifferent_access) || params.try(:to_unsafe_h)
raise ArgumentError, "unable to process params" if indifferent_params.nil?
attributes += searchable_includes
attributes.reduce(all) do |relation, attribute|
relation.search_attribute(attribute, indifferent_params, CurrentUser.user)
end
@@ -406,14 +407,6 @@ module Searchable
where(id: ids).order(Arel.sql(order_clause.join(', ')))
end
def search(params = {})
params ||= {}
default_attributes = (attribute_names.map(&:to_sym) & %i[id created_at updated_at])
all_attributes = default_attributes + searchable_includes
search_attributes(params, *all_attributes)
end
private
def qualified_column_for(attr)