show do
attributes_table do
tag_row :state
end
end
index do
tag_column :state
end
If you want to customize the tag's colors. You need to define css classes matching enumerize attribute values. For example: if you have the Bill
model with:
class Bill < ActiveRecord::Base
# Enumerize
extend Enumerize
enumerize :state, in: [:pending, :rejected, :approved], default: :pending
# Rails Enum
enum status: { active: 0, archived: 1 }
end
You will need to define inside your_app/app/assets/stylesheets/active_admin.css.scss
the following:
$pending-color: #FF9900;
$rejected-color: #FF0000;
$approved-color: #08A510;
.status_tag {
&.pending { background: $pending-color; }
&.rejected { background: $rejected-color; }
&.approved { background: $approved-color; }
}
tag_column
also can receive the boolean parameter interactive
. If interactive
is true, it will render a select2 input to change the value of the attribute when the tag is clicked:
index do
tag_column :state, interactive: true
tag_column :status, interactive: true
end