Welcome Guest, Not a member yet? Register   Sign In
ORM conceptual question

[eluser]Neeraj Kumar[/eluser]
Hi all!

I am using Datamapper as ORM for my application. But I think i need an answer to a question.

ORMs generally saves a lot of time. but makes controller functions very big. What I need to know is that is it correct to use big ORM functions in controller. I mean they make our controllers FAT, which is not generally adviced, right?

what are your insights?

[eluser]Colin Williams[/eluser]
ORM is not a replacement for models. All that logic should happen in a model or models

ORM tends to minimize model size by handling most CRUD, but this is suppose to make it easier to getting down to focusing on what the model should really be doing.

My guess is you are missing that models do more than merely encapsulate data - they handle common manipulations of that data as well. My guess if you have a fat controller then you are doing the models job in the controller, which ORM in no way indicates you should do - it's just likely made you hesitant to do other things with your model.

My Payment model, for instance, handles submitting payment to my credit card processor, converts the raw post-back confirmation into meaningful information, and then handles saving and retrieving this data in a meaningful way. These aren't view functions, and it makes little sense to put them in a controller because this is functions unique to Payments not to any specific page.

Theme © iAndrew 2016 - Forum software by © MyBB