views:

25

answers:

1

My one column name is "usage" and it's conflicting with mysql keywords.

To solve out that issue i was passing usage like `usage` with ActiveRecord. That solved my problem.

CsvHeader.find(:all,:conditions => ["`usage` = ?",usage]))

Right now i am attaching db2 as my database. db2 is not accepting &&. so i have replaced && with and. Another problem db2 causing with ` backsinglequote.

This working with mysql but not with db2.

CsvHeader.find(:all,:conditions => ["`usage` = ?",usage]))

Any help ??

A: 

Try

CsvHeader.all :conditions => { :usage => usage }

or

CsvHeader.find_all_by_usage usage

You can combine multiple and'ed conditions into one hash or by using find_all_by_XXX_and_YYY...

hurikhan77