Files
fizzy/app/models/bucket.rb
T
Jason Zimdars 28a569c49b Tickets
2025-03-17 21:24:08 -05:00

24 lines
673 B
Ruby

class Bucket < ApplicationRecord
include Accessible, Broadcastable, Filterable, Subscribable
belongs_to :account
belongs_to :creator, class_name: "User", default: -> { Current.user }
has_many :bubbles, dependent: :destroy
has_many :tags, -> { distinct }, through: :bubbles
validates_presence_of :name
after_create :ensure_workflow_exists
scope :alphabetically, -> { order(name: :asc) }
private
def ensure_workflow_exists
unless account.workflows.exists?
workflow = account.workflows.create!(name: "Default Workflow")
[ "Maybe?", "Not now", "Done" ].each { |name| workflow.stages.create!(name: name) }
end
end
end