-
Notifications
You must be signed in to change notification settings - Fork 26
Upgrading
ClassyEnum 4.0 supports Rails >= 3.2.x and Ruby >= 1.9.3. If you want to use ClassyEnum >= 4.0, you will need to be running at least these versions.
ClassyEnum is no longer included in all Active Record classes and must be explicitly included in any Active Record classes you want to use it with.
class Alarm < ActiveRecord::Base
classy_enum_attr :priority
endclass Alarm < ActiveRecord::Base
include ClassyEnum::ActiveRecord
classy_enum_attr :priority
endThe serialize_as_json option has been removed in favor of overriding #as_json in your enum subclasses.
See notes below if moving from 1.x to 3.x
In addition to some removing a few unnecessary methods, there are changes to how enum classes are defined. The enum_classes macro has been removed in favor of inferring them from the subclass names. Subclasses must now follow a naming convention that uses the parent class as a namespace:
class Parent < ClassyEnum::Base
enum_classes :child1, :child2
end
class ParentChild1 < Parent
end
class ParentChild2 < Parent
endclass Parent < ClassyEnum::Base
end
class Parent::Child1 < Parent
end
class Parent::Child2 < Parent
endPrior to 2.0, enum classes were implicity defined and were only required when overriding methods or properties. As of 2.0, all enum classes must explicity subclass a child of ClassyEnum::Base. If you used the generator, there are no changes to the existing structure.
Built-in Formtastic support has been removed. See the note at the bottom of this readme for more information how how to enable it.