Topic: How to Keep Controllers Lean?

In my am finding that my controllers are growing increasingly larger. For example, I have a people controller. Naturally I have all of the CRUD actions in there but I have also been adding some "custom" actions to help with displaying data. (IE. -> I have am attendance action that displays a single persons attendance, there is a birthdays action to display a list of birthdays, etc.)

Should I consider moving these custom actions to keep my controllers lean? If yes, where should I put them (helper or model)? And finally, once they are moved how do you access them?

I am really looking for some philosophy and ideas more than anything. smile

Boo.

Re: How to Keep Controllers Lean?

Philosophy: Fat model, lean controller.

Anything to do with data management/manipulation should go in the model that makes the most sense.
Anything to do with html/view that is reusable should go in your helper.

You will ask the model for the birthdays and attendance, this is how you would call it in your controller and views:

@person.birthdays
@person.attendance

Re: How to Keep Controllers Lean?

Now, THAT makes sense.

THANKS! smile

Anyone else have any other thoughts / tips??

Boo.

Re: How to Keep Controllers Lean?

I agree with the monkey.  If you need extra data on the view, then put that logic in the model and just call it from the view (i.e. @person.birthdays).

However, if you need an entirely separate view then I think its ok to make extra methods in your controller (outside of CRUD).  I have some print views that I use custom methods for in my view.  Unless someone knows of a way around this?