I have this line of code inside of my controller.
user = User.find_by_email(params[:email])
Should I have to worry about SQL injection with this line of code? Most of the examples I’ve seen for sql injection involve conditionals. I would assume this is a yes but want some outside input.
You should only have to worry about this in SQL fragment methods like
where(),connection.execute()orfind_by_sql(), although if you want to be sure you can use a method likesanitize_sql(). I would recommend reading through this, most notably section 8 for your case.Update:
For example
would evaluate to
which would be sanitized.