Class: Tag
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Tag
- Extended by:
- FriendlyId
- Defined in:
- app/models/tag.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.bookmarked(bookmark_ids, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/tag.rb', line 25 def self.bookmarked(bookmark_ids, = {}) count = Tag.count count = Tag.default_per_page if count == 0 unless bookmark_ids.empty? = Tag.search do with(:bookmark_ids).any_of bookmark_ids order_by :taggings_count, :desc paginate(page: 1, per_page: count) end.results end end |
Instance Method Details
#save_taggings ⇒ Object
37 38 39 |
# File 'app/models/tag.rb', line 37 def save_taggings taggings.collect(&:taggable).each do |t| t.save end end |
#tagged(taggable_type) ⇒ Object
41 42 43 |
# File 'app/models/tag.rb', line 41 def tagged(taggable_type) self.taggings.where(taggable_type: taggable_type.to_s).includes(:taggable).collect(&:taggable) end |