I can''t figure out the correct format of the :join call to paginate. I looked at the find_all method docs since that is what paginate uses. I have tried many combinations and none seem to work (find_all gets all fancy and rewrite the query so I can''t force values in there). Here is my call: @item_pages, @items = paginate(:items, :conditions => conditions, :order_by => "created_at desc", :join => "LEFT JOIN feeds on feeds.id=feed_id") Of course the above doesn''t work. I have tried many permutations, but I am sure it''s something silly I am doing. Any tips? Guess it would cool if paginate would be changed to use find(:all) so you could use :include (no that is not a volunteer! :) ) Thanks for any help. Sean
Hi Sean, here''s something i''m using, and it works fine: @distributor_pages, @distributors = paginate :distributor, :per_page => 30, :order_by => ''last_name'', :conditions => ''deleted=0'', :join => ''LEFT JOIN distorders ON (distorder_id=distributors.id)'' don''t know how your model looks like but have you tried with '':item'' instead of '':items'' ?? bests, Richard> I can''t figure out the correct format of the :join call to paginate. > I looked at the find_all method docs since that is what paginate > uses. I have tried many combinations and none seem to work (find_all > gets all fancy and rewrite the query so I can''t force values in there). > > Here is my call: > > @item_pages, @items = paginate(:items, :conditions => > conditions, :order_by => "created_at desc", :join => "LEFT JOIN feeds > on feeds.id=feed_id") > > Of course the above doesn''t work. I have tried many permutations, > but I am sure it''s something silly I am doing. Any tips? Guess it > would cool if paginate would be changed to use find(:all) so you > could use :include (no that is not a volunteer! :) ) > > Thanks for any help. > > Sean > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Pretty much same as I have, here is the SQL it generates which is invalid as you can see: SELECT COUNT(*) FROM items i , LEFT JOIN feeds ON (feed_id=feeds.id) WHERE customer_id = 1 On Jun 22, 2005, at 2:51 AM, Richard Piacentini wrote:> Hi Sean, > > here''s something i''m using, and it works fine: > > @distributor_pages, @distributors = paginate :distributor, > :per_page => 30, > :order_by => ''last_name'', > :conditions => ''deleted=0'', > :join => ''LEFT JOIN distorders ON > (distorder_id=distributors.id)'' > > don''t know how your model looks like but have you tried with '':item'' > instead of '':items'' ?? > > bests, > > Richard > > > >> I can''t figure out the correct format of the :join call to paginate. >> I looked at the find_all method docs since that is what paginate >> uses. I have tried many combinations and none seem to work (find_all >> gets all fancy and rewrite the query so I can''t force values in >> there). >> >> Here is my call: >> >> @item_pages, @items = paginate(:items, :conditions => >> conditions, :order_by => "created_at desc", :join => "LEFT JOIN feeds >> on feeds.id=feed_id") >> >> Of course the above doesn''t work. I have tried many permutations, >> but I am sure it''s something silly I am doing. Any tips? Guess it >> would cool if paginate would be changed to use find(:all) so you >> could use :include (no that is not a volunteer! :) ) >> >> Thanks for any help. >> >> Sean >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
sorry it works for me cause i''m using the latest rails from svn, and this patch is already applied: http://dev.rubyonrails.com/ticket/1156 Richard> Pretty much same as I have, here is the SQL it generates which is > invalid as you can see: > > SELECT COUNT(*) FROM items i , LEFT JOIN feeds ON (feed_id=feeds.id) > WHERE customer_id = 1