exists? weirdness

This works:

@items = Item.find( :all, :conditions => [ "category_id = ? AND position = ?", category_id, position ] )     if @items.size > 0 ...

But this:

if Item.exists?( :conditions => [ "category_id = ? AND position = ?", category_id, position ] )...

Gives this error despite the documentation for Active Record Query Interface which says "Further more, exists takes a conditions option much like find:"...

SQLite3::SQLException: no such column: items.conditions: SELECT "items".id FROM "items" WHERE ("items"."conditions" IN ('category_id = ? AND position = ?',4,3.0)) LIMIT 1

Any idea why?

Many TIA, Craig

This works:

@items = Item.find( :all, :conditions => [ "category_id = ? AND position = ?", category_id, position ] )    if @items.size > 0 ...

But this:

if Item.exists?( :conditions => [ "category_id = ? AND position = ?", category_id, position ] )...

Try it like:    Item.exists?(["category_id = ? AND position = ?", category_id,
position]) Or:    Item.exists?(:category_id => category_id, :position => position)

It wants the *value* of the conditions key in the options hash.

-Rob

Gives this error despite the documentation for Active Record Query Interface which says "Further more, exists takes a conditions option much like find:"...

SQLite3::SQLException: no such column: items.conditions: SELECT "items".id FROM "items" WHERE ("items"."conditions" IN ('category_id = ? AND position = ?',4,3.0)) LIMIT 1

Any idea why?

Many TIA, Craig >

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com