title: Mongoid Relational Queries Syntax
body: <p>I'm having issues using a has_and_belongs_to_many relationship. I have the following:</p>
  
  <pre><code>class User
    include Mongoid::Document
  
    has_and_belongs_to_many :subjects
  end
  
  class Subject
    include Mongoid::Document
    field :name, :type =&gt; String
    attr_accessible :name
    has_and_belongs_to_many :users
  end
  </code></pre>
  
  <p>Then in my controller I am trying to find all users that have a particular subject:</p>
  
  <pre><code>class UsersController &lt; ApplicationController
      def index
          @users = User.where('subjects.name' =&gt; 'Physics')
      end
  end
  </code></pre>
  
  <p>Am I going about this the right way?</p>