mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 15:05:26 +08:00
14 lines
387 B
Ruby
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
|