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

field "type" parameter should use a symbol arg instead of a class

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

      It's generally bad practice to put constants in configs, for example to prevent load-order errors.

      The field parameter type should allow a symbol arg and deprecate usage of constants for Mongoid 8.0.

      field :first_name, type: :string   # new format
      field :last_name, type: String     # deprecated
      

      There are some gems that use custom types, one that comes to mind is Mongoid::EncryptedString. We should provide an API to register new symbol values as aliases to those types, e.g.:

       

      Mongoid.register_type :encrypted_string, Mongoid::EncryptedString

      As long as the class defines `mongoize` and `demongoize` it should work.

       

       

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: