rubocop / rails-style-guide

A community-driven Ruby on Rails style guide
http://rails.rubystyle.guide
6.47k stars 1.06k forks source link

Suggestion: Add notes about `.none()` #337

Open ydakuka opened 1 year ago

ydakuka commented 1 year ago

I suggest to add paragraph about using method .none().

Let's say we have the following samples:

User.where(id: nil)
User.where(id: 0)
User.where(id: [])
User.where(id: {})
User.limit(nil)
User.limit(0)

All these lines can be replaced with the code:

User.none
andyw8 commented 1 year ago

Are those other approaches common? Perhaps you could check on https://github.com/eliotsykes/real-world-rails