enum

rails 4.1.0+ support

class AnyModel < ActiveRecord::BaseActiveRecord
  enum any_attribute: { value1: 0, value2: 1, value3: 3 }
end

AnyModel::any_attributes
# => { value1: 0, value2: 1, value3: 3 }

AnyModel.any_attributes
# => { value1: 0, value2: 1, value3: 3 }

AnyModel.any_attributes[:value1]
# => 0

Reference

results matching ""

    No results matching ""