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?
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?
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}%”])
Hi Jorge,
Its work for me.
Thank You!
Try this:
Model.find( :all, :conditions => [“fieldname like ?”, ‘%keyword’] )
cu jc
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs