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



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

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

#tagged_with_uri(uri) ⇒ Object



52
53
54
# 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