Forum: Ruby on Rails Ajax On Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
62598951b4281b878edf81328c90c8a7?d=identicon&s=25 Anil Vadhavane (anil)
on 2006-02-17 11:53
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?
5a16c9ccbb3c8e9fa1839f85d05a1cf8?d=identicon&s=25 Jorge Sousa (Guest)
on 2006-02-17 12:20
(Received via mailing list)
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}%"])
62598951b4281b878edf81328c90c8a7?d=identicon&s=25 Anil Vadhavane (anil)
on 2006-02-17 12:46
Hi Jorge,

Its work for me.
Thank You!
79204bd2e447be21d643855e17ff7bd0?d=identicon&s=25 Jens-Christian Fischer (Guest)
on 2006-02-18 14:51
(Received via mailing list)
Try this:

Model.find( :all, :conditions => ["fieldname like ?", '%keyword'] )

cu jc
This topic is locked and can not be replied to.