scinote-web/app/models/concerns/searchable_by_name_model.rb
2019-02-26 11:01:15 +01:00

14 lines
387 B
Ruby

# frozen_string_literal: true
module SearchableByNameModel
extend ActiveSupport::Concern
included do
def self.search_by_name(user, teams = [], query = nil, options = {})
return if user.blank? || teams.blank?
viewable_by_user(user, teams)
.where_attributes_like("#{table_name}.name", query, options)
.limit(Constants::SEARCH_LIMIT)
end
end
end