Skip to content

Commit 5d906af

Browse files
committed
Add section for redundant all
1 parent e18585f commit 5d906af

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,23 @@ User.where.not(status: 'active', plan: 'basic')
11011101
User.where.not('status = ? AND plan = ?', 'active', 'basic')
11021102
----
11031103

1104+
=== Redundant `all` [[redundant-all]]
1105+
Using `all` as a receiver for Active Record query methods is redundant.
1106+
The result won't change without `all`, so it can be removed.
1107+
1108+
[source, ruby]
1109+
----
1110+
# bad
1111+
User.all.order(:created_at)
1112+
User.all.find(id)
1113+
User.all.where(id: ids)
1114+
1115+
# good
1116+
User.order(:created_at)
1117+
User.find(id)
1118+
User.where(id: ids)
1119+
----
1120+
11041121
== Migrations
11051122

11061123
=== Schema Version [[schema-version]]

0 commit comments

Comments
 (0)