How fat my rails model is?

The quick way to do it besides going to the file you want to check, use methods/instance_methods and count

[1] pry(main)> User.methods(false).count

=> 100

So User model responds to 100 methods.

[2] pry(main)> User.instance_methods(false).count

=> 0

Let's remember Sandi Metz rules:

  • Prefer small methods. Between one and five lines is best.

  • Prefer small classes with a single, well-defined responsibility. When a class exceeds 100 lines, it may be doing too many things.

That's all folks!, thank you very much for reading, follow me on twitter @zazvick

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Director of Engineering at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!