I'd like to use the following query for my Rails 4 application but am concerned about SQL injection attacks:
@persons = People.where("persons.name LIKE ?", "%#{params[:search]}%")
Can somebody show me the safe way to write the above statement? I've tried the following but am not sure if it is SQL-injection-proof:
search = "%" + params[:search] + "%"
@persons = People.where("persons.name LIKE ?", search)
Thanks!