Forum: Ruby on Rails Limited eager loads and conditions on the eager tables

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A4b45b0467e28925b5103b50f7d39e5d?d=identicon&s=25 Mark Beattie (Guest)
on 2006-01-19 04:07
(Received via mailing list)
Hi,

Why are limited eager loads and conditions on the eager tables
incompatible?

Doing a find(:all) without :include causes a select * query to be
generated,
which means the id fields everwrite each other if associated tables are
included using :joins.

But using :include, if conditions are placed on the tables listed in
:joins
then Rails throws an exception when :limit is included too.

Ordinarily I'd just leave out the limit, but I'm populating a div of
limited
size with draggables so I can't have overflow set to auto, or they can't
be
dragged out of the div...

Anyone have any suggestions as to how to use conditions on joined tables
with
limits as well? I'm thinking I might have to use :joins with :select and
name
the columns specifically, but it makes for messy code.

thanks,
mark
This topic is locked and can not be replied to.