← Back to Upcase

When to put methods in controllers and when to put them in models


(Jameson Trinker) #1

I’m familiar with the phrase “fat model, skinny controller”, but I’m curious if anyone has any questions I can ask myself when deciding to put a method in a controller or model. When should you pick one over the other?

Thank you.


(Mike Burns) #2

I think of it in terms of “tell don’t ask”. The controller should be full of methods that deal with controller stuff: session, params, request, render, redirect_to, and so on. Anything that can be moved out, is.

I also strive to use RESTful controllers as much as possible, which means controllers have up to seven public methods and however many private methods are needed to deal with strong parameters and before_filters.