A Ruby gem for adding enumerated attributes with I18n support and ORM integrations like ActiveRecord and Mongoid.
Enumerize is a Ruby gem that adds enumerated attribute support to Ruby classes, particularly in Rails applications. It allows developers to define attributes with a fixed set of values (like roles or statuses), providing I18n translations, validations, and helper methods. It solves the problem of managing predefined options in models without cluttering code with constants or manual validation logic.
Ruby on Rails developers and Rubyists using ORMs like ActiveRecord or Mongoid who need to handle enumerated fields (e.g., user roles, order statuses) with clean code and internationalization support.
Developers choose Enumerize for its seamless integration with popular ORMs, built-in I18n support, and rich feature set like scopes, predicate methods, and form helpers—all while keeping model definitions simple and maintainable.
Enumerated attributes with I18n and ActiveRecord/Mongoid support
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports localization files for human-readable values with flexible scoping, including defaults and custom i18n_scope options, as shown in the I18n Support section.
Works seamlessly with ActiveRecord, Mongoid, MongoMapper, and Sequel, including database migrations and scopes, reducing boilerplate code across different Ruby ORMs.
Generates predicate methods (e.g., user.admin?) and provides ActiveRecord scopes for easy querying, enhancing developer productivity in model interactions.
Automatically integrates with SimpleForm and Formtastic to generate dropdowns or radio buttons, simplifying form creation without manual collection setup.
Adds inclusion validation by default, which can conflict with custom validations; disabling it requires explicit skip_validations options, adding complexity.
Values are defined statically at the class level and cannot be easily modified at runtime, limiting flexibility for applications with evolving data sets.
Cannot define scopes when using the :multiple option for array-like attributes, hindering query optimization for fields that hold multiple values.