Only this two objects, nothing else (it's a very simple app that
queries GPS devices and stores it's locations showing them on georss).
And the querying is simple too.
In controller: @devices = Device.all
In view: @devices.each { |d| d.lat }
And in model: def lat; locations.first.lat; end
If Device.all returns one object I get what I want. If it returns
multiple objects (at least two) it seems datamapper tries to load the
data eagerly, and joins the queries, making things worse.
On júl. 26, 07:31, Kevin <[email protected]> wrote:
> There must be some funny business in your models.... try stripping
> them down. If you still get troubles, post a full example script as a
> github gist or somewhere to try?
>
> My test with similar models (I think?) in my app. Many topics, each
> one has a user. Each topic has a board.
>
> User.get(18).topics.all(:order => [:created_at.asc]).first.board
>
> Results in:
>
> SQL (0.4ms) SELECT `id`, `name`, `email` FROM `users` WHERE `id` =
> 18 ORDER BY `id` LIMIT 1
> SQL (0.2ms) SELECT `id`, `board_id` FROM `topics` WHERE `id` =
> 268674981 ORDER BY `id`
> SQL (0.2ms) SELECT `id`, `title`, `topics_count` FROM `boards`
> WHERE `id` = 3834 ORDER BY `id` LIMIT 1
>
> Sorry if I've confused something, but it seems like it should work as
> expected to me!
--
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.