Ajax On Rails


#1

Hi,

I want database query in rail for ‘LIKE’

i.e in sql it something like.
"SELECT * FROM tablename where filedname LIKE ‘%keyword%’ " etc.

What for rail?


#2

Check the ActiveRecord docs, look for the find_by_sql method.

Somthing like
MODEL_CLASS.find_by_sql([“SELECT * FROM TABLENAME WHERE FIELD LIKE ?”,
“%#{VALUE}%”])


#3

Hi Jorge,

Its work for me.
Thank You!


#4

Try this:

Model.find( :all, :conditions => [“fieldname like ?”, ‘%keyword’] )

cu jc