[LRUG] Field definitions in AR models

Luke Morton lukemorton.dev at gmail.com
Sat Feb 21 11:02:25 PST 2015


Does this new feature in active record change things?

http://edgeapi.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html

On 20 February 2015 at 08:34, Tom Stuart <tom at codon.com> wrote:

> On 18 Feb 2015, at 11:33, Thomas Buckley-Houston <tom at tombh.co.uk> wrote:
> > My problem with poking around the console is that it's counter to the
> > MVC philosophy of using the Model to describe your domain.
>
> I’m surprised nobody’s come out with the obvious-but-unhelpful smartarse
> answer yet, so I’ll just say it to clear the air:
>
> The underlying problem is that Active Record is fit for use as a
> persistence layer, but not as your domain model. Ideally you would use it
> for the single concern of trafficking data between the database and a
> genuine layer of domain objects, which of course can be as rich,
> descriptive and documented as you like, being the single source of truth
> for model concerns. In this arrangement the only role of Active Record
> instances is to map directly onto the database tables and fields, so it
> makes sense for them to not re-represent this information in code; they’re
> simply the database reflected in a Ruby mirror. Your actual model objects
> can be much more than this.
>
> Of course experience has shown that this is very difficult to achieve in
> practice because of the way that Rails and AR work, but hey, why let
> reality spoil our fun?
>
> Cheers,
> -Tom
> _______________________________________________
> 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/20150221/82df9d51/attachment.html>


More information about the Chat mailing list