Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 933 Bytes

enumerize_integration.md

File metadata and controls

48 lines (36 loc) · 933 Bytes

Enum Integration

Tag Row

show do
  attributes_table do
    # another attributes...
    tag_row :state
  end
end

Tag Column

index do
  # another attributes...
  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: [:rejected, :approved]

  # 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:

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