I am wondering where I should define my callbacks. I have a user model
and a few callbacks: before_save, after_save, etc.
I can define each callback in the model, but it is getting a bit messy
and overcrowded especially as I am using restful_auth. The other option
is to move the callbacks definitions in a user_observer. However
restful_auth which is supposed to be an example for good coding practice
defines before_save :encrypt_password inside the model.
So what to do?
- Stuff callbacks inside the model, but the model can become a mess
- Separate callbacks from model, this is a step beyond mvc, cleaner,
but it requires having to move back and forth between files and
remembering to register the callbacks.
How do you do that? What is today’s commonly accepted best practice?
What about validations? For instance before_validation, shouldn’t I also
move it to an observer?