Rails: Skinny Controller vs. Fat Model, or should I make my Controller Anorexic?

There is an old saying,

Smart data structures and dumb code
works a lot better than the other way
around.

Everything you have described is about how one piece of data relates to another. That itself is your clue that the logic for those relationships, including validation should be in the model or database layer.

An anorexic controller is a sign of well-designed (smart?) data. My experience tells me that the more effort you put into designing your data, the less code you have to write overall.

Controllers are best at parsing inputs, calling the appropriate models, and then formatting the outputs.

Leave a Comment