title: Mongoid greater than date or not nil
body: <p>I have two models</p>
  
  <pre><code>class Conversation
    include Mongoid::Document 
  
    field :last_moderated_at, type: DateTime
    has_many :messages
  end
  
  class Message
    include Mongoid::Document
    include Mongoid::Timestamps
  end
  </code></pre>
  
  <p>I want to get the list of all messages that were created after the moderation date, or all of them if the moderation date is nil</p>
  
  <p>I had expected the following to work</p>
  
  <pre><code>conversation.messages.where(
        :created_at.gte =&gt; conversation.last_moderated_at
      )
  </code></pre>
  
  <p>But apparently the comparison with nil fails (when <code>last_moderated_at == nil</code>)</p>
  
  <p>Do I have no choice but to use an <code>if/else</code> or is there a mongoDB operator of type <code>greater than</code> that also works when compared to nil dates ?</p>
  
  <p>EDIT : A simpler example : <code>Conversation.where(:created_at.gte =&gt; nil).count</code> will always return 0</p>