fc56ad9d7c
- Switch to binary 16 for UUID keys - Remove AccountScopedRecord base class, all model use binary uuids now - Fix the search sql to serialize uuids properly - Patch the MySQL schema dumper to output binary lengths
22 lines
516 B
Ruby
22 lines
516 B
Ruby
class Tag < ApplicationRecord
|
|
include Attachable, Filterable
|
|
|
|
belongs_to :account, default: -> { Current.account }
|
|
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.open.count
|
|
end
|
|
end
|