The project that I am working on uses rails 4.0.2 and postgress 9.4.7 I am new to rails and I wonder if rails active record creates prepend statement
When I run this line:
User.where(id:123)
The log says:
SELECT "users".* FROM "users" WHERE "users"."id" = 123
But when I run this line:
When I run this line:
User.find(123)
The log says:
SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 123]]
Why is the difference? Which is more secure? I think that that first version using where() is only escaping the data and the second version using find() uses prepend statement is that correct? Is it possible to use where but to create a query like the second version?
2 useful links
What is the purpose of ActiveRecord::Relation#bind?
http://apidock.com/rails/v4.0.2/ActiveRecord/FinderMethods/find_one