Skip to content

Commit

Permalink
Add section for redundant all
Browse files Browse the repository at this point in the history
  • Loading branch information
masato-bkn committed Aug 11, 2023
1 parent e18585f commit 5d906af
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,23 @@ User.where.not(status: 'active', plan: 'basic')
User.where.not('status = ? AND plan = ?', 'active', 'basic')
----

=== Redundant `all` [[redundant-all]]
Using `all` as a receiver for Active Record query methods is redundant.
The result won't change without `all`, so it can be removed.

[source, ruby]
----
# bad
User.all.order(:created_at)
User.all.find(id)
User.all.where(id: ids)
# good
User.order(:created_at)
User.find(id)
User.where(id: ids)
----

== Migrations

=== Schema Version [[schema-version]]
Expand Down

0 comments on commit 5d906af

Please sign in to comment.