title: Mongo / Rails Mongoid index on embedded field
body: <p>I'm getting something incredibly simple wrong, and not sure what I'm doing wrong. Fairly new to Mongo</p>
  
  <p>Using Rails 3.2.6 with MongoDB and Mongoid. Trying to add an index to an embedded field.</p>
  
  <p>I have a model 'Scheme', which has embedded 'Referals'. "Referal" has a field 'to_code' (string). I want to index this field.</p>
  
  <pre><code>class Scheme
    include Mongoid::Document
    include Mongoid::Timestamps
    embeds_many :referals
    index "referals.to_code" =&gt; 1
  
  class Referal
    include Mongoid::Document
    include Mongoid::Timestamps
    embedded_in :scheme
  </code></pre>
  
  <p>when I run 'rake db:mongoid:create_indexes' this fails with this error:</p>
  
  <pre><code> Not a Mongoid parent model: app/models/referal.rb
   rake aborted!
   Invalid index specification {"referals.to_code"=&gt;1}; should be either a string, symbol, or an array of arrays.
  </code></pre>
  
  <p>As far as I can tell this follows the Mongoid documentation exactly, so not sure what I'm doing wrong.
  Any help much appreciated.</p>