Forum: Ruby on Rails What is wrong with my sql statement??

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.
brutyn_nick (Guest)
on 2005-11-17 13:06
(Received via mailing list)
hey, i want a list of callers, 10 per page, depending on which firm id
(in table
geotags)

@callerid_pages, @callerids = paginate :caller_ids, :conditions =>
["caller_ids.geotag_id = geotags.id and geotags.firm_id = ?" , firm_id],
:order_by => "geotags.address1 ASC" , :include=>[:geotag], :per_page =>
10

and i get this error

#42S02Unknown table 'geotags' in where clause: SELECT COUNT(*) FROM
caller_ids
WHERE (caller_ids.geotag_id = geotags.id and geotags.firm_id = 1)

thanks
christopher.k.hall (Guest)
on 2005-11-17 13:45
(Received via mailing list)
try using :joins instead of :include

@callerid_pages, @callerids = paginate :caller_ids, :conditions =>
["ci.geotag_id = gt.id <http://gt.id> and gt.firm_id = ?" , firm_id],
:order_by => "gt.address1 ASC" , :joins => "as ci, geotags as gt",
:per_page
=> 10
This topic is locked and can not be replied to.