Skip to content

Commit 7ad8bb9

Browse files
authored
Merge pull request #270 from eugeneius/hash_conditions
Extend query conditions guideline to cover equality
2 parents 03f02a3 + 035aeaf commit 7ad8bb9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.adoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,18 @@ User.find_by(email: email)
858858
User.find_by(first_name: 'Bruce', last_name: 'Wayne')
859859
----
860860

861-
=== Where Not [[where-not]]
861+
=== Hash conditions [[where-not]] [[hash-conditions]]
862862

863-
Favor the use of `where.not` over SQL.
863+
Favor passing conditions to `where` and `where.not` as a hash over using fragments of SQL.
864864

865865
[source,ruby]
866866
----
867+
# bad
868+
User.where("name = ?", name)
869+
870+
# good
871+
User.where(name: name)
872+
867873
# bad
868874
User.where("id != ?", id)
869875

0 commit comments

Comments
 (0)