سؤال

So I'm building a Github based application with octokit and the rails api, I have the basic idea of what I want to do, but I'm not too sure where to do it. Is it better to manipulate fetched data in the model or in the controller, any help would be appreciated! Thanks ya'll.

هل كانت مفيدة؟

المحلول

I've found the best way to figure out a question like that is imagine that you were writing an statless, UI less API for the application that was going to be called by various different clients, like a web service.

If the "manipulation" has to do with presentation in some UI of the objects represented by the models, then that sounds like controller. If its a "behavioral" feature of the objects themselves, or the type of manipulation that would be useful no matter what the presentation (for example a list of objects in some useful order based on the model properties) than I like to put that kind of thing in the model.

Hope that is somewhat helpful.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top