[LRUG] Field definitions in AR models

Roland Swingler roland.swingler at gmail.com
Wed Feb 18 08:17:20 PST 2015


> it seems easier to write the migration approach ... you’d have to write
something that diffs what is in the models versus the current state of the
schema

Yes - specifically there is no way to tell the difference between renaming
a column and deleting a column and adding another in this approach.

I think the rationale was Don't Repeat Yourself, and because of the above
problem you have to put the definition in the Database.

R

On Wed, Feb 18, 2015 at 4:04 PM, Frederick Cheung <
frederick.cheung at gmail.com> wrote:

> 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
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20150218/863ffab0/attachment-0003.html>


More information about the Chat mailing list