In my Rails app, I have two classes each with the same enum for status. Code climate is complaining about duplication.class Enrolment < ActiveRecord::Base  has_many :enrolment_presentations  has_many :presentations, through: :enrolment_presentations  enum status: {    'Pending' => 1,    'Suspended' => 2,    'Cancelled' => 3,    'Pass' => 4,    'Fail' => 5,    'DPR' => 6,    'Unknown' => 7,    'Enrolled' => 8  }endclass EnrolmentPresentations < ActiveRecord::Base  belongs_to :enrolment  belongs_to :presentation  enum status: {    'Pending' => 1,    'Suspended' => 2,    'Cancelled' => 3,    'Pass' => 4,    'Fail' => 5,    'DPR' => 6,    'Unknown' => 7,    'Enrolled' => 8  }endHow would you go about removing this duplication?
Duplication of enum across two models
ruby;ruby on rails
ActiveRecord enums are exposed through a class method with the pluralized attribute name, so I recommend the following code. However, I would highly recommend making the enums symbols instead of strings for compatibility. Also, enrollment is spelled with two l's. Note that you can control the capitalization of DPR using inflections.class Enrollment < ActiveRecord::Base  has_many :enrollment_presentations  has_many :presentations, through: :enrollment_presentations  enum status: {    pending: 1,    suspended: 2,    cancelled: 3,    pass: 4,    fail: 5,    dpr: 6,    unknown: 7,    enrolled: 8  }endclass EnrollmentPresentations < ActiveRecord::Base  belongs_to :enrollment  belongs_to :presentation  enum status: Enrollment.statusesend