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

[Feature request] Allow change of default value for fields in inherited model

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0
    • Affects Version/s: None
    • Component/s: None

      Hello,

      Would it be possible to add an easy way to change a field default value outside the field definition?

      Pseudo code:

      class SomeDocument
      include Mongoid::Document
      field :data, :type => String, :default => 'I love mongoid'
      end

      class BetterDocument < SomeDocument
      default_value_for :data, 'Mongoid loves me'
      end

      at the moment, the way I use which generates a warning is

      class SomeDocument
      include Mongoid::Document
      field :data, :type => String, :default => 'I love mongoid'
      end

      class BetterDocument < SomeDocument
      field :data, :type => String, :default => 'Mongoid loves me'
      end

            Assignee:
            Unassigned Unassigned
            Reporter:
            muichkine Olivier Milla
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: