Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Latest commit

 

History

History
72 lines (55 loc) · 1.46 KB

aasm_integration.md

File metadata and controls

72 lines (55 loc) · 1.46 KB

AASM Integration

State Row

show do
  attributes_table do
    state_row :state
  end
end

State Column

index do
  state_column :state
end

The name of the state will be the class name (rejected, approved, etc.), but you can pass a hash of options to map different states with tag colors.

state_column(:state, states: { destroyed: "rejected" })

You will need to define inside your_app/app/assets/stylesheets/active_admin.css.scss the following:

.status_tag {
  &.rejected { background: $rejected-color; }
  &.approved { background: $approved-color; }
}

Named state machines support

When the state machine name is different from :default, you must provide it in the machine attribute. This is needed when using multiple state machines in the same class.

For example, if the machine is defined like the AASM multiple states per class sample:

class SimpleMultipleExample
  include AASM
  aasm :move, column: :moving_state do
    ...
  end

  aasm :work, column: :working_state do
    ...
  end
end

Then you should define your admin like this:

index do
  state_column :moving_state, machine: :move
  state_column :working_state, machine: :work
end

show do
  attributes_table do
    state_row :moving_state, machine: :move
    state_row :working_state, machine: :work
  end
end