rubocop / ruby-style-guide

A community-driven Ruby coding style guide
https://rubystyle.guide
16.46k stars 3.4k forks source link

User.all.length call #718

Closed zhisme closed 6 years ago

zhisme commented 6 years ago

Hey there. Can someone told me, why this is not marked as extremely bad? Is there any real reason to load all users into memory? I can't even imagine. It would be nice if you show me real-case usage of this example.

# good - if you really need to load all users into memory
User.all.length

length method

timacs commented 6 years ago

This issue should go to the Rails Style Guide, not Ruby Style Guide. Maybe, it's even better to comment directly at https://github.com/bbatsov/rails-style-guide/pull/224.

zhisme commented 6 years ago

@tim-teufel Yeah, you are right, thanks!