782259a678
Previously when an item was `created`, we'd track the event, update the summary text, and broadcast the notifications. But now that we have a draft state, we shold do all of this when it's published instead.
17 lines
338 B
Ruby
17 lines
338 B
Ruby
module Bubble::Draftable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
enum :status, %w[ drafted published ].index_by(&:itself)
|
|
|
|
scope :published_or_drafted_by, ->(user) { where(status: :published).or(where(creator: user)) }
|
|
end
|
|
|
|
def publish
|
|
transaction do
|
|
published!
|
|
track_event :published
|
|
end
|
|
end
|
|
end
|