My selection of products from a Products table looks like this:
# Get products on department promotion @products = Product.find(:all, :select => "distinct products.*", :order => " product_id ", :joins => " inner join category_products " + " on products.product_id = category_products.product_id " + " inner join categories " + " on category_products.category_id = categories.category_id ", :conditions => ["products.on_department_promotion = ? " + " AND categories.department_id = ?", true, params[:id]])
When I try to substitute a pagination statement for the find statement, for example:
@products = Product.paginate(:all, :page => params[:page], :select => "distinct products.*", :order => " product_id ", :joins => " inner join category_products " + " on products.product_id = category_products.product_id " + " inner join categories " + " on category_products.category_id = categories.category_id ", :conditions => ["products.on_department_promotion = ? " + " AND categories.department_id = ?", true, params[:id]])
the paginage gem/plugin can't interpret the select distinct statement an typically gives an error like:
SQLite3::SQLException: near "*": syntax error: SELECT count(distinct products.*) AS count_distinct_products_all FROM products inner join etc., etc., etc.
Can anyone tell me how to paginate the results of the original find statement?
Carson