Files
fizzy/app/models/tag.rb
T
Jason Zimdars 27285a3dcb Display tag counts in the filter menu
- Provides a little information scent
- Prevents being surprised by "no results"
2025-07-08 15:57:29 -05:00

21 lines
456 B
Ruby

class Tag < ApplicationRecord
include Attachable, Filterable
has_many :taggings, dependent: :destroy
has_many :cards, through: :taggings
validates :title, format: { without: /\A#/ }
normalizes :title, with: -> { it.downcase }
scope :alphabetically, -> { order("lower(title)") }
scope :unused, -> { left_outer_joins(:taggings).where(taggings: { id: nil }) }
def hashtag
"#" + title
end
def cards_count
cards.count
end
end