Skip to content

1.x to 2.x Migration Guide

Lukas Westermann edited this page Jul 17, 2014 · 3 revisions

Version 2.x is a rewrite to ensure a more modular and even less obtrusive variant of support enum fields in ActiveRecord or other ruby objects. Due to this it is backwards incompatible with 1.x. This page highlights the changes between 1.x and 2.x and should help with the migration. If anything important is missing, feel free to add, thx.

  • The as_enum method now accepts different and less options, see the README.md for the support options
  • Getting the "raw" enum value requires now to type User.genders[:male] instead of User.male
  • User.genders returns a SimpleEnum::Enum
  • ActiveRecord/Mongoid only: Added User.females which returns a relation similar to where(gender_cd: self.class.genders[:female])
  • Instance level methods still exist, i.e. gender=, gender, gender?(x), male?, female?, male!, female! and the dirty methods
  • The only remaining translation methods is User.human_enum_name(enum, key), to build select options also check out SimpleEnum::ViewHelpers which provides a enum_option_pairs method
Clone this wiki locally