Module: LeanTag::Taggable::ClassMethods
- Defined in:
- lib/lean_tag/taggable.rb
Instance Method Summary collapse
-
#tagged_with(list, filter = "tags") ⇒ Object
Returns all records which include at least one of the passed tags.
-
#tags(filter = "tags") ⇒ Object
Get all tags used by this class.
Instance Method Details
#tagged_with(list, filter = "tags") ⇒ Object
Returns all records which include at least one of the passed tags
30 31 32 33 34 35 |
# File 'lib/lean_tag/taggable.rb', line 30 def tagged_with(list, filter="tags") list = list.split(LeanTag.config.delimiter) if list.is_a?(String) tag_ids = Tag.matches(list).pluck(:id) taggings = Tagging.where(record_type: self.name, tag_id: tag_ids).where(filter: filter) return self.where(id: taggings.select(:record_id).distinct) end |