What is wrong with my sql statement?


#1

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


#2

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