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