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

make default value working for existed documents

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      suppose the former attribute declaration is <code>field :position</code>, after deployed in production for a while, there're many documents with empty position,
      so I've to changed to <code>field :position, :default => 'manager'</code>, but the default value only works for new records, it could be terrific to overload the default value when loading the existed documents.

      currently my ugly crack is:

      field :position, :default => 'manager'
      def position;
      self[:position] || 'manager'
      end

            Assignee:
            Unassigned Unassigned
            Reporter:
            Aaron2Ti Aaron Tian [X]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: