Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5424

ActiveRecord Parity: Add "enum" type (similar to ActiveRecord::Enum)

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Rails 4.1 introduced ActiveRecord::Enum. This article gives a good overview of Rails' functionality and helper functions.

      Nearly all apps will have some use case for enums. In Mongoid they are typically strings or symbols. It would be great if Mongoid could support something like the following:

       

      field :status, type: :enum, values: [:started, :pending, :done]
      

       

      I believe there is a mongoid_enum gem, however, since its in AR core, I think there is a good argument to make it core in mongoid as well. Possibly could be done after some of the type refactoring.

            Assignee:
            Unassigned Unassigned
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: