title: Rails - Mongoid : newly added fields in model giving nil for old data objects
body: <p>I have model as follows: </p>
  
  <pre><code>class User
    include Mongoid::Document
    field :name
  end
  </code></pre>
  
  <p>After saving a few user objects to the database I added some more fields:</p>
  
  <pre><code>class User
    include Mongoid::Document
    include Mongoid::Timestamps::Created
    field :name
    field :birthdate
  end
  </code></pre>
  
  <p>Now, I expect I can use the following snippet:</p>
  
  <pre><code>@user = User.all
  @user.each do |u|
     puts u.name
     puts u.birthdate.strftime(#someFormat)
     puts u.created_at.strftime(#someFormat)
  end
  </code></pre>
  
  <p>Unfortunately, because my old <code>user</code> objects don't have <code>birthdate</code> keys, I receive this error: <code>strftime called on nil class</code>.</p>
  
  <p>Question:</p>
  
  <ul>
  <li>How can I handle such cases with Mongoid? In MySQL, when a column is added it gets added to old rows as well. But if I see in MongoDB, it doesn't add new fields as keys for old data.</li>
  <li>This problem also exists with the <code>created_at</code> field as old data doesn't have that field either.</li>
  </ul>
  
  <p>I am looking for good way to solve this, checking for <code>nil</code> conditions each time is not a scalable option because the number of fields will continue increasing.</p>