Module: Shared::Tags::ClassMethods

Defined in:
app/models/concerns/shared/tags.rb

Instance Method Summary collapse

Instance Method Details

#tagged_with_keyword(keyword) ⇒ Scope

Returns only those instances with tags that use the kewyord.

Returns:

  • (Scope)

    only those instances with tags that use the kewyord



60
61
62
# File 'app/models/concerns/shared/tags.rb', line 60

def tagged_with_keyword(keyword)
  joins(:tags).where(tags: {keyword:})
end

#tagged_with_uri(uri) ⇒ Object



52
53
54
55
# File 'app/models/concerns/shared/tags.rb', line 52

def tagged_with_uri(uri)
  joins("JOIN tags t1 on t1.tag_object_type = '#{self.base_class.name}' AND t1.tag_object_id = #{self.base_class.name.tableize}.id JOIN controlled_vocabulary_terms k1 on k1.id = t1.keyword_id")
  .where('k1.uri = ?', uri)
end