I'm not sure I completely understand the question, but if I had a block I'd do
something like:

@bar_1 = Bar.get(params[:id => foo_1.id])
#this will grab all the parameters of that bar based on the id

then you can do

@bar_1.bar

#or 

@bar_1.id

#to get any of the parameters of that object

Quoting Yuri <[email protected]>:

> For example, if Foo belongs to Bar, given foo_1 has a bar.id == 1
> 
> bar_1 = Bar.get(1)
> bar_1b = foo_1.bar
> 
> results in two identical selects. So the question is, is there a
> recommended approach to preventing duplicate queries resulting from
> necessity of accessing the same object through different paths inside
> a single repository block, in a DM-esque way?
> 
> Note I ask not because I've an extra query or two, but because in
> complex pages listing dozens of parent objects with dozens of
> children, I'm ending up with a hundred or so extra queries.
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "DataMapper" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/datamapper?hl=en.
> 
> 


-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to