File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1101,6 +1101,26 @@ User.where.not(status: 'active', plan: 'basic')
1101
1101
User.where.not('status = ? AND plan = ?', 'active', 'basic')
1102
1102
----
1103
1103
1104
+ === Redundant `all` [[redundant-all]]
1105
+
1106
+ Using `all` as a receiver for Active Record query methods is redundant.
1107
+ The result won't change without `all`, so it can be removed.
1108
+
1109
+ [source, ruby]
1110
+ ----
1111
+ # bad
1112
+ User.all.find(id)
1113
+ User.all.order(:created_at)
1114
+ users.all.where(id: ids)
1115
+ user.articles.all.order(:created_at)
1116
+
1117
+ # good
1118
+ User.find(id)
1119
+ User.order(:created_at)
1120
+ users.where(id: ids)
1121
+ user.articles.order(:created_at)
1122
+ ----
1123
+
1104
1124
== Migrations
1105
1125
1106
1126
=== Schema Version [[schema-version]]
You can’t perform that action at this time.
0 commit comments