- Use 'defaults' scope in the localization file for the attributes that used across several models. This will help to avoid conflicting keys with model names and attribute names. Example:
en:
enumerize:
defaults:
sex:
male: Male
female: Female
You still can use the old solution without "default" scope:
en:
enumerize:
sex:
male: Male
female: Female
(by @nashby)
- Integration with SimpleForm's
input_field
(by @nashby) - Support multiple attributes in Active Record #becomes method (by @lest)
- Add ability to specify localization scope with
i18n_scope
option (by @dreamfall)
- Fix Rails Admin integration when custom values are used (by @brenes)
- Fix RSpec integration using enumerize with Spring (by @winston)
- Return proper RSpec failure message for enumerized attribute with default value (by @nashby)
- Return proper RSpec description for enumerized attribute without default value (by @andreygerasimchuk)
- Do not try to set default value for not selected attributes (by @nashby)
- Fix uniqueness validation with Active Record (by @lest)
- Fix loading of attributes with multiple: true in mongoid (by glebtv)
- Serialize value as scalar type (by @ka8725)
- Give priority to model specific translation definition. See example here (by @labocho)
- Allow lambda in default value (by @adie)
- Add predicate methods to the multiple attributes (by @nashby)
- Add RSpec matcher (by @nashby)
- Add
*_value
method that returns actual value of the enumerized attribute (useful for attributes with custom values) (by @tkyowa)
- Make validation work when
write_attribute
is using for setting enumerized values (by @nashby) - Validates enumerized values when enumeration is included via module (by @nashby) and (by @lest)
- Don't raise error when enumerized attribute is already defined. (by @lest)
- Use inclusion error message for invalid values (by @lest)
- Add
:only
andexcept
options to theAttribute#options
method. (by @thehappycoder and @randoum) - ActiveRecord scopes. (by @lest, @banyan and @nashby)
- Support for RailsAdmin (by @drewda)
- Return correct default value for enumerized attribute using
default_scope
with generated scope @nashby - Allow either key or value as valid (by aghull and @lest)
- Use default enum value from db column (by @lest)
- Always return Enumerize::Set for multiple attributes (by @nashby)
The previous method of adding enumerize to a class was deprecated. Please use
extend Enumerize
instead of include Enumerize
.
- SimpleForm support for multiple attributes. (by @nashby)
- Formtastic support for multiple attributes. (by @nashby)
- Array-like multiple attributes. (by @lest)
Legacy support was dropped. The following versions are supported:
- Ruby 1.9.3+ (including JRuby and Rubinius)
- Rails 3.2+
- Formtastic 2.2+
- SimpleForm 2+
- Mongoid 3+
- Ability to define predicate methods on enumerized object. (by @lest)
- Accept a values hash to store an attribute using custom values (e.g. integers) (by @lest)
- Correctly assign default value to handle mass assignment in Active Record (by @lest)
- Call super in attribute accessors if available (by @lest)
- Ability to enumerize attributes in a module and then include it into classes (by @lest)
- Add error to a model when attribute value is not included in allowed list (by @lest)
- Return humanized value if there are no translations (by @nashby)
- Integration with SimpleForm (by @nashby)
- Integration with Formtastic (by @lest)
- Make attribute accessors to work with ActiveRecord 3.1.x (by @lest)
- Mongoid support (by @lest)
- Boolean methods (by @Dreamfa11)