0

In my Controllers I'm using many find_by_sql() stuff, and to avoid SQL injection I'm building my SQL statements as hashes as follows

Beneficiary.find_by_sql(["SELECT * FROM beneficiaries WHERE project_id=? AND cso_id IN(SELECT user_id FROM user_projects INNER JOIN users ON  user_projects.user_id=users.id)",params[:id]])

Is it enough to avoid SQL injection? or need more?

Unknown Coder
  • 1,510
  • 2
  • 28
  • 56

1 Answers1

2

Yes, It's enough, you use placeholder for parameters, there is no SQL injection problem.

xdazz
  • 158,678
  • 38
  • 247
  • 274