Class: Thing
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thing
- Includes:
- Concerns::Model::BaseThing
- Defined in:
- app/models/thing.rb
Class Method Summary collapse
Methods included from Concerns::Model::BaseThing
#lists, #special_characters_excluded
Class Method Details
.suggest(term) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'app/models/thing.rb', line 4 def self.suggest(term) known_things = Thing.order(:name).where("name LIKE ?", "%#{term}%").limit(10).map do |t| { id: t.id, name: t.name } end (known_things + Wikidata.search(term, known_things)).map do |item| item[:value] = item[:name] item end end |