When do you create your own class?

When do you create your own class in rails?

This book will help you.
http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882/ref=pd_sim_b_2

Hi Scott – can you be more specific? Is your question about when to use non-ActiveRecord classes in Rails apps?

@mjankowski Yes it is sorry.

@scott

This is my 4th attempt at answering this question and I think it’s hard to answer because you’re starting with the wrong premise. You’re implicitly saying, “ActiveRecord is the default, when do I break out”, but I think you need to start the other way and say, “All my classes are naked ruby classes to start.” and so the question becomes when do you add active record? The obvious answer is when you need the DB functionality.

Not sure where you are in your rails career, but this is a bad habit that a lot of folks (my self most of all) get into and if all your objects are inheriting from ActiveRecord::Base you’re probably doing something wrong.

1 Like