title: How-to: User has fans
body: <p>I need users to be able to become fans of other users. How should I design/set this up?</p>
  
  <p>I need to be able to view details of user fans.</p>
  
  <p>For example. I have user: Foo. Foo has 3 fans. I'd like to be able to find the names of Foo's fans. As such:</p>
  
  <pre><code>foo = User.first
  foo.name (returns 'Foo')
  foo.fans.first.user.name (should return 'bar', since 'bar' is a fan of 'foo')
  </code></pre>
  
  <p>This is how I have it set up at the moment:</p>
  
  <pre><code>User model:
    embeds_many :fans
    references_many :fans
  
  Fan model:
    embedded_in :user, :inverse_of =&gt; :fans
    referenced_in :user
  
  In console, I do:
    User.first.fans.create!(:user =&gt; User.first)
  </code></pre>
  
  <p>and I get:
    <strong>Mongoid::Errors::InvalidCollection: Access to the collection for Fan is not allowed since it is an embedded document, please access a collection from the root document.</strong> I think the problem is, because the fan model is embedded in the user model which has a self-reference to the user model as well....</p>
  
  <p>Your thoughts will be much appreciated.</p>