Reputation: 307
i need to build a ActiveRecord query in RoR environment, with 'exact match' and 'LIKE' as 'Where' params.
this is an example:
@find = Person.where(name: @f_name, surname: @f_surname, address: @f_address)
in the exaple, name and surname are exact match, but address must be something like "like %@f_address%", but ii can't goal it !!!
i tried also
@find = Person.where('name LIKE ? and surname LIKE ? and address LIKE ?', @f_name, @f_surname, '%#{@f_address}%')
But the result is the same!
Can someone help me? Thanks!
Upvotes: 0
Views: 680
Reputation: 30056
I think the only issue is that you need double quote for interpolation. Try
"%#{@f_address}%"
Upvotes: 2