lib/express_admin/search.rb in express_admin-1.7.12 vs lib/express_admin/search.rb in express_admin-1.7.13
- old
+ new
@@ -4,12 +4,12 @@
@search_results = []
@tables_traversed = []
@scope = scope
@params = params
self.search_parent_tables(scope)
- @search_results = @search_results | scope.basic_search(params) if scope.columns.map(&:type).include? :string
- @search_results = @search_results | scope.fuzzy_search(params) if scope.columns.map(&:type).include? :string
+ @search_results = @search_results | scope.basic_search(params) if searchable?(scope.columns)
+ @search_results = @search_results | scope.fuzzy_search(params) if searchable?(scope.columns)
@search_results
end
def self.search_parent_tables(scope)
@associations = scope.reflect_on_all_associations(:belongs_to).map(&:name)
@@ -45,7 +45,14 @@
end
end
string_columns
end
+ def self.searchable?(columns)
+ type = columns.map(&:type)
+
+ type.include?(:string) || type.include?(:text)
+ end
+
+ private_class_method :searchable?
end
end