-
Notifications
You must be signed in to change notification settings - Fork 2
AASM extensions
Petr Mlčoch edited this page Sep 22, 2022
·
1 revision
- You can add color to a state. This is displayed in console as box before event state
- You can hide some (automation) events from users using
private: true
option - You can add
email_modal: true
option to an AASM event to force a confirmation modal with an option to send an email to the record'semail
attribute.
Examples:
aasm do
state :submitted, initial: true, color: "red"
state :processing, color: "yellow"
state :registered, color: "orange"
states = MyRecord.aasm.states.map(&:name)
event :process, email_modal: true do
transitions to: :processing, from: states.without(:processing)
end
event :register, private: true do
transitions from :processing, to: :registered
end
end
Modal uses certain record's class methods as input defaults:
class MyRecord < ApplicationRecord
def self.aasm_email_default_subject(event)
"My default subject"
end
def self.aasm_email_default_text(event)
"My default\n\nsimple_format text"
end
end
If relevant params are found and present, Folio::Console::Api::AasmController
sends an email via the Folio::AasmMailer
mailer.