I’m trying to run this query:
Result.where('link = #{site}').present?
where site is a string. However the problem with the code above is that because of the single quotes, site will not be interpolated.
If i try
Result.where("link = #{site}").present?
I get a syntax error.
How can I write this?
You will be hacked next day you use it. It has severe SQL injection issue.
What you have to do is this:
Or if you need something other than equality then this syntax is better:
You can read more here.