title: Has_and_belongs_to_many index mongoid
body: <p>I have a many to many relations between users and projects, and it works perfectly. However I want to model this scenario in <strong>mongoid</strong>:</p>
  
  <pre><code>db.projects.insert(
    { 
      "name" : "Test project",
      "memberships" : [
        {
          "user_id" : ObjectId("4d730fcfcedc351d67000002"),
          "role" : "administrator"
        },
        {
          "role" : "editor",
          "user_id" : ObjectId("4d731fe3cedc351fa7000002")
        }
      ]
    }
  )
  </code></pre>
  
  <p>I read the documentation for Mongoid, and for relations I have to do this:</p>
  
  <pre><code>has_and_belongs_to_many :preferences, index: true
  </code></pre>
  
  <p>And create like this:</p>
  
  <pre><code>rake db:mongoid:create_indexes
  </code></pre>
  
  <p>But when I persist, it saves the relationship but the index isn't created. <a href="https://stackoverflow.com/questions/5209072/modeling-many-to-many-through-with-mongoid-mongodb">Modeling many-to-many :through with Mongoid/MongoDB</a> asks exactly the same question, but the answer does not show how to do it in Mongoid unless I missed something.</p>