Class: Topic

Inherits:
ControlledVocabularyTerm show all
Includes:
Shared::Taggable
Defined in:
app/models/topic.rb

Constant Summary

Constant Summary

Constants inherited from ControlledVocabularyTerm

ControlledVocabularyTerm::ALTERNATE_VALUES_FOR

Instance Attribute Summary

Attributes inherited from ControlledVocabularyTerm

#definition, #name, #project_id, #type, #uri, #uri_relation

Class Method Summary (collapse)

Methods inherited from ControlledVocabularyTerm

generate_download, #uri_relation_is_a_skos_relation

Methods included from Housekeeping

#has_polymorphic_relationship?

Class Method Details

+ (Object) find_for_autocomplete(params)



12
13
14
15
16
# File 'app/models/topic.rb', line 12

def self.find_for_autocomplete(params)
  term = "#{params[:term]}%"
  where_string = "name LIKE '#{term}' OR name ILIKE '%#{term}' OR name = '#{term}' OR definition ILIKE '%#{term}'"
  ControlledVocabularyTerm.where(where_string).where(project_id: params[:project_id], type: 'Topic')
end