[LRUG] Form objects is Ruby

Kasper Grubbe kawsper at gmail.com
Fri Jul 24 03:09:46 PDT 2015


One of the purest forms of this that I have found is the "Password-change"
use case. Because it deals with virtual fields as well. So lets say you
have a User-model, and that model have a password-field that needs to be
changed.

The database would look like this:

User
  id
  username
  password

But what the user most often is presented with is these fields:

Current password
New password
New password confirmation

So you have a case where the interface doesn't match the structure of your
database.

It is quite easy to create these things in Rails with ActiveModel, but
Virtus is cool too. Here is my code for the model (Uses ActiveModel):
 https://gist.github.com/kaspergrubbe/43bf53850df44db41717


--
Kasper Grubbe

Phone: (+45) 42 42 42 74 or (+44) 77 07 12 17 81
Skype: kasper.grubbe
Mail: kaspergrubbe at gmail.com
Web: http://kaspergrubbe.dk

On Thu, Jul 23, 2015 at 5:47 PM, Peter Saxton <peterhsaxton at gmail.com>
wrote:

> As part of a series on Domain Driven Design I have written an article on
> building and using form objects.  Which I hope is of interest to some here.
>
>
> http://insights.workshop14.io/2015/07/23/application-border-control-with-ruby-form-objects.html
>
> Feedback is welcome
>
> --
> Building globe.workshop14.io
> Creator www.londonlayout.co.uk
> Works for Workshop 14 <http://workshop14.io>
>
> _______________________________________________
> 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/20150724/0429864b/attachment-0003.html>


More information about the Chat mailing list