I'm not sure what you mean by "eager loading" of Data, here. If you eager load all the Children through the Parents, you have everything you need to get the URL of the Data attachment. URLs are calculated, not stored. The data stored for the Data attachment is stored on the Child model, and it's only the file name, size, content type, and updated_at. You don't need to make any queries to get the URL for the attachment. You will need to make more method calls, but that doesn't incur the same cost.
For example, this should only require two hit to the database, total:
parent = Parent.all(:include => :child)
parent.children.map do |child|
child.data.url
end
It would be one for all the Parents and one for all the associated Children, since that's how AR does eager loading.
Is that not what you're seeing?
> --
> Individuals over processes. Interactions over tools.
>
> Agile Rails training from thoughtbot, the makers of Paperclip, Clearance, Shoulda, & Factory Girl:
> http://thoughtbot.com/services/training
>
> The Paperclip group:
> http://groups.google.com/group/paperclip-plugin
>
> To post to this group, send email to
> papercli...@googlegroups.com
>
> To unsubscribe from this group, send email to
> paperclip-plug...@googlegroups.com
--
Jonathan Yurek, Founder and CTO
thoughtbot, inc.
617.482.1300 x114
http://thoughtbot.com/
http://twitter.com/thoughtbot