-
Notifications
You must be signed in to change notification settings - Fork 62
1.x to 2.x Migration Guide
Joshua Pinter edited this page Dec 16, 2018
·
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_enummethod now accepts different and less options, see theREADME.mdfor the support options. - Getting the "raw" enum value requires now to type
User.genders[:male]instead ofUser.male. -
User.gendersreturns aSimpleEnum::Enuminstead ofSimpleEnum::EnumHash. - ActiveRecord/Mongoid only: Added
User.femaleswhich returns a relation similar towhere(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 outSimpleEnum::ViewHelperswhich provides aenum_option_pairsmethod. - The
as_enum: truevalidation is no longer used.