Which is the best place to put business logic?

Hello, I wonder if it’s better to put business logic in the controller
or in the model (I presume model is better)

Eg. client controller, disable_account action

client = Client.find(params[:id])
client.send_pending_invoices()
client.login_enabled = false
client.receive_newsletter = false

or

client = Client.find(params[:id])
client.disable_account() # and put the whole stuff in this method ?

Which is the best one ?

Thanks

On Jul 26, 2006, at 4:19 AM, nuno wrote:

or

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.

cr

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs