ruby-on-railsrubyaasm

AASM transition from but except one state


I have AASM with ActiveRecord model.

Have many statuses and events with their transitions. I want to create event that will allow transition from any state except one.

event :set_vacant_pass do
  transitions to: :vacant_pass, from: ??
end

Solution

  • After some digging, i just decided to have simple solution:

    event :set_vacant_pass do
      transitions to: :vacant_pass, from: Vacation.man_statuses.except('vacant_pass').keys
    end
    

    This will allow event transition from any state except vacant_pass.

    (man_status is enum column and used for AASM)