title: mongoid, creating references with roles
body: <p>I am quite new to mongoDB and I'm just using it for a new rails project I'm working on.
  What I wanted to do now is, having an (embedded) document reference another collection, but with different roles.</p>
  
  <p>Somehow this doesn't seem to work. I know, that I can't define a relation from an external collection to my embedded one. So in my case, I cannot acces the Locations from my User and I'm fine with that. Still, I need to define the <code>referenced_in :location</code> part, because otherwise I get an error message <code>undefined method 'name' for nil:NilClass</code> when I try to add a new Location to the Place.</p>
  
  <p>So that's just the preface. My actual <em>problem</em> is, that these roles thing doesn't seem to work. When I create a new Location like that in a Place <code>locations.create(:user_a =&gt; some_user)</code>, then also <code>user_b</code> is set to that user.</p>
  
  <p>Is there any way to make this working? Or am I doing something wrong?</p>
  
  <pre><code>class Place
    include Mongoid::Document
    embeds_many :locations
  end
  
  class Location
    include Mongoid::Document
    embedded_in :place, :inverse_of =&gt; :locations
    references_one :user_a, :class_name =&gt; "User" #, :stored_as =&gt; :array
    references_one :user_b, :class_name =&gt; "User" #, :stored_as =&gt; :array
  end
  
  class User
    include Mongoid::Document
    referenced_in :location, :inverse_of =&gt; :dropper
    referenced_in :location, :inverse_of =&gt; :picker
  end
  </code></pre>