On Jul 26, 2006, at 4:19 AM, nuno wrote:
Hello, I wonder if it’s better to put business logic in the
client = Client.find(params[:id])
client.disable_account() # and put the whole stuff in this method ?
Your second choice is correct. The controller merely glues the model
to the view. Changing the internal state of the model should be done
purely by methods on that object.
I think this example is the trivial case since quite often the business
logic spans many models. Certainly encapsulate any and all business
logic that is model-specific into that model, but do you really want to
have one model making use of another to accomplish the business logic?
I think that you have no choice but to put the rest in the controller.
Am I missing something?