Why mongoid cannot query embedded document?
<p>Through large data, I realize it is not supported in Mongoid. For example, I have two model defenition:</p>

<pre><code>class User
  include Mongoid::Document
  embeds_one :homepage
end

class Homepage
  include Mongoid::Document
  embedded_in :user
end
</code></pre>

<p>In this example, User and Homepage is a one-to-one relation. In RDBMS, there is a refrence key in homepage table. In mongo, we can embed homepage into user. In this way, we can query users like <code>User.all</code>; however, we cannot query homepages exactly like <code>Homepage.all</code>. </p>

<p>Maybe <em>has_one</em> macro is what I want. I would design some apis for users, such as <code>/users</code>; on the other hand, I would also design some apis for homepages, such as <code>/homepages</code>. However, if I set <code>has_one :homepage</code> in User model, I lose such additions: I cannot query users or homepages according to fields of both User and Homepage.</p>