Question

I'm using acts_as_taggable_on in rails and I'm trying to get a listing of all Products that have yet to be tagged. In MySQL the following query worked:

  def self.untagged
    available.find(:all, 
    :joins => %{LEFT JOIN taggings ON products.id = taggings.taggable_id AND taggings.taggable_type = "Product"}, 
    :conditions => "taggings.id IS NULL AND for_sale IS true",
    :order => "products.updated_at DESC"
    )

In Postgres, however, I get the error that the column "Product" does not exist.

The generated SQL appears to be:

SELECT count(*) AS count_all FROM "products"  LEFT JOIN taggings ON products.id = taggings.taggable_id AND taggings.taggable_type = "Product" WHERE (taggings.id IS NULL AND for_sale IS true) AND (products.date_expires > '2011-09-12') ) 

Any suggestions on how to get this working? I'd prefer to use an active record friendly way so that it may still work in MySQL. But that's something I'd be willing to sacrifice.

Thanks in advance..

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top