How does one write a prepared statement with LIKE using find_by_sql.
For example the problem with soemthing like this is that extra quotes
are put around the ?
Product.find_by_sql([“SELECT * FROM products WHERE name LIKE ‘%?%’”],
params[:name])
How does one write a prepared statement with LIKE using find_by_sql.
For example the problem with soemthing like this is that extra quotes
are put around the ?
Product.find_by_sql([“SELECT * FROM products WHERE name LIKE ‘%?%’”],
params[:name])
Perhaps you could try
Product.find_by_sql([“SELECT * FROM products WHERE name LIKE ?”],
“%#{params[:name]}%”)