[LRUG] Field definitions in AR models

Frederick Cheung frederick.cheung at gmail.com
Wed Feb 18 08:04:22 PST 2015


On 18 February 2015 at 12:00:20, Thomas Buckley-Houston (tom at tombh.co.uk) wrote:
Thanks for the replies.  

I think Tim Diggins most gets what I'm on about, thanks :)  

My problem with poking around the console is that it's counter to the  
MVC philosophy of using the Model to describe your domain. Code *as*  
documentation and all that. In pretty much every other MVC framework  
and ORM I've come across, fields are described in the model. My  
question is really curiosity as to why this is? Is AR's fieldless  
models a known pattern? Or is there a historical reason in AR's  
development for it?  


I think for a definitive answer you’d have to ask DHH, but it’s been the way it currently is since migrations were added (https://github.com/rails/rails/commit/eac7cf0b0608132673220d9045b8ff51dc0804e1). Off the top of my head it seems easier to write the migration approach (at least the first implementation of it) than a model based declarative approach where you’d have to write something that diffs what is in the models versus the current state of the schema.

Fred
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20150218/f8743ccf/attachment.html>


More information about the Chat mailing list