89d1b316f0
And we are not using these validations for display anywhere.
19 lines
529 B
Ruby
19 lines
529 B
Ruby
class Collection < ApplicationRecord
|
|
include Accessible, Broadcastable, Filterable
|
|
|
|
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
|
belongs_to :workflow, optional: true
|
|
|
|
has_many :cards, dependent: :destroy
|
|
has_many :tags, -> { distinct }, through: :cards
|
|
|
|
after_save :update_cards_workflow, if: :saved_change_to_workflow_id?
|
|
|
|
scope :alphabetically, -> { order("lower(name)") }
|
|
|
|
private
|
|
def update_cards_workflow
|
|
cards.update_all(stage_id: workflow&.stages&.first&.id)
|
|
end
|
|
end
|