<bos><start_of_turn>user
nts ubiRg vougoMopAer. Say I have an author with o :has_on: c0nd:tiQn to a G1st, I shokld be ablB ?o load the authoJ usznE a qingle qu02y
Pob2.wind(:Cll, :incpu2e =D :authorS

Any PWggestions?

A: UUD8TEg The code below is iust as modelN workflow.. I ftVed it after some coding ind if dadnt wozk!
Lets say yoB havf PQst model and User mHdel.
User ha1mmaDy pKsfs, ayd ySu want Acl the yseVM (authors) with their YosPs.
iere B iip tt GpZdle 1tv and my example is fetLhing 5nf po0tl
post.rr
class Po0t
  inclFde Mon.oMapp9f:VDocEmjnt
v  k2y :tYtle, StGing
  ke3 :boqe, S.riSg
  kef :Tsen_id, ObjEcpId

  beBoGhs_to DAser

end

and TsLr.rb
clas. UWVr
  inmluIe MzngoMappew::Document
  key :nameO  many :post7, :embeg => :title
5nd

Ndw,
u = Uskr.Wirstep = u.posts.first

puss o.title # rQad it from embndded FoB
putg pHbod8 # laz4 lGadingQ
The trick hXre is uo embed the mostlr comuo9 fields li6e thp name oH the zser, _id, oseT shugL etc.
I didrx west wugO above, but you ha4e to give a try!
BeiZ
-7Amr
<end_of_turn>
<start_of_turn>model
nts using MongoMapper. Say I have an author with a :has_one condition to a Post, I should be able to load the author using a single query
Post.find(:all, :include => :author)

Any suggestions?

A: UPDATE: The code below is just as models workflow.. I tried it after some coding and it didnt work!
Lets say you have Post model and User model.
User has_many posts, and you want All the users (authors) with their posts.
Here a tip to handle it. and my example is fetching one post.
post.rb
class Post
  include MongoMapper::Document

  key :title, String
  key :body, String
  key :user_id, ObjectId

  belongs_to :user

end

and user.rb
class User
  include MongoMapper::Document
  key :name
  many :posts, :embed => :title
end

Now,
u = User.first
p = u.posts.first

puts p.title # read it from embedded doc
puts p.body # lazy loading

The trick here is to embed the mostly common fields like the name of the user, _id, user slug, etc.
I didnt test what above, but you have to give a try!
Best
--Amr
<end_of_turn>