| > Models are intended to serve only as an abstraction to the database.
> They are meant to be 'models of data'. TL;DR: MVC Model is Logical model - business object (invoice) with business logic (delete_line_item), Rails Model is Physical model - persistence layer for RDBMS (add, update, delete, find rows). In all but the most trivial applications, the latter assertion contradicts the former, and the former, is just outright wrong. In MVC, Models are meant to model the logical objects of the system.
An invoice is an object one which one acts. It is probably composed of several other objects (header, line items, addresses, etc.) which may in turn be composed of other objects. Only the most trivial application have a one-to-one mapping from RDBMS rows to objects, which is what the OP asserts. One does not write one's Models with the persistence layer in mind, one writes them with the business logic in mind. So to me, this is where Rails gets the name Model wrong. The untrained, just starting out with rails learn that business logic goes in the model, so there is goes. But add_address() has no business living int he rails Model file for the invoice header, because that model is meant to be dedicated to manipulating invoice_header records in our RDBMS. |