Problem using hashes with 'find' method

The following works for me:

Mymodel.find(:all, :conditions => "fieldOne = 'Example1' AND myobject_id = '1'")

but when I try

Mymodel.find(:all, :conditions => { :fieldOne => Example1, :myobject_id => 1 })

That's missing quotes around Example1. I suggest you cut and paste your script/console session inputs and outputs exactly, so we can see what's happening.

Using a hash works fine for me, so something else is going on here.

... I get an error message

ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'fieldOneExample1myobject_id1' in 'where clause': SELECT * FROM mymodels WHERE (fieldOneExample1myobject_id1)

This looks like the hash is being converted to a string before it's getting to AR, so we need to see *exactly* what you're doing.

I would verify that you are running the latest stable version of Ruby on Rails. The hash-based condition clauses were a semi-recent addition to the framework, and judging by the flattening of the hash into a string, my first guess is that that is the case.

Taylor Singletary, Reality Technician