<img style="border: none; background:none; width: 0; height: 0;" src="https://share.polymail.io/v2/z/a/NWE4NDJlNDIxY2Qw/VeCXTjWZpIYvjHLVh-3VV_w3FjxN5FnCMFB06Baga1MtOeso71Ri2ZdX5uCf87O4LUXVDQ7f7Duvfd0vqQEteJYortxuAkhyCjZj0ZSPE-eMUYhLxcWp8SdfKQF4j19v5talaMZ_RGPBM9HaGoY=.png" alt="" width="0px" height="0px" border="0" /><div> </div>
<div>
To clarify my poor explanation: the fact that we used the session as an answer store is incidental - it was just the quickest thing which worked. It would be trivial to change the answer store class to save to some other store (eg redis) and just store a key in the session.<br><br>
</div>
<div id="psignature"><div>Duncan Stuart</div></div>
<div class="gmail_extra"><br/><div class="gmail_quote"><div dir="ltr">On Wed, 14 Feb 2018 at 12:25 Rob Anderson <rob.anderson> <<a href="mailto:Rob Anderson <rob.anderson@paymentcardsolutions.co.uk>">Rob Anderson <rob.anderson> </rob.anderson></a>> wrote:<br/></rob.anderson></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><style><![CDATA[a, pre, code, a:link, body { word-wrap: break-word !important; }]]></style>
<div dir="ltr">I feel it's best to avoid the session for this sort of thing if possible.<div><br/></div>
<div>We use a form object to mediate between the params and the Rails model itself. The form object is responsible for performing the partial validation at each step of the form process. The Rails model validates the whole thing when the data is complete. The form object can delegate individual field validation tasks to the Rails model to keep DRY, as necessary.</div>
<div><br/></div>
<div>State is handled by rendering the previous step's form fields as hidden fields in step 2. So all state is held by the browser. This can mean that a multi-step form is implemented in a single Rails view + action, although it doesn't have to be.</div>
<div><br/></div>
<div>Rob</div>
</div>
<p>_______________________________________________
<br/>Chat mailing list
<br/><a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a>
<br/>Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org">http://lists.lrug.org/pipermail/chat-lrug.org</a>
<br/>Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org">http://lists.lrug.org/options.cgi/chat-lrug.org</a>
<br/>List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a>
<br/></p>
<br/><div class="gmail_quote">On 14 February 2018 at 12:12, Duncan Stuart <span dir="ltr"><<a href="mailto:dgmstuart@gmail.com" target="_blank">dgmstuart@gmail.com</a>></span> wrote:<br/><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><img style="border:none;background:none;width:0;height:0" src="https://share.polymail.io/v2/z/a/NWE4NDI1NGJjZTIw/h1IdIWAtPg1TwSfRTKVpwwGou3FoE1--78cUkqJeOiM427PgYlskRLKGBTnbY08tDpQCNH3_VswmAM5d9Ff2sEPHrshJ6Nbq5U1Wmd8FFXxN_ivVAGCnWaGZCQwF4IXcq6RWXFVdlkYgWTqx7f8=.png" alt="" width="0px" height="0px" border="0"/><div> </div>
<div>
I don’t know of a gem - it’s a recurring problem, and a fiddly one since the concept of state is different from standard Rails CRUD. </div><div><br/></div><div>We’ve used an approach of storing a hash of answers in the session: <a href="https://github.com/LBHackney-IT/maintain-my-home/blob/develop/app/models/selected_answer_store.rb" target="_blank">https://github.com/<wbr>LBHackney-IT/maintain-my-home/<wbr>blob/develop/app/models/<wbr>selected_answer_store.rb</wbr></wbr></wbr></a>, and elsewhere configuring the branching structure of a set of similar multiple-choice questions in YAML: <a href="https://github.com/LBHackney-IT/maintain-my-home/blob/develop/app/models/question_set.rb" target="_blank">https://github.com/<wbr>LBHackney-IT/maintain-my-home/<wbr>blob/develop/app/models/<wbr>question_set.rb</wbr></wbr></wbr></a></div><div><br/></div><div>This approach was borrowed from some <a href="http://gov.uk" target="_blank">gov.uk</a> site (I forget which but you can find it in the commit history). Iirc that project additionaly had an object responsible for deciding what the next question should be, based on the previous answers. </div><div><br/></div><div>Good luck!<span class="HOEnZb"><font color="#888888"><br/><br/>
</font></span></div><span class="HOEnZb"><font color="#888888">
<div id="m_-437691239638132493psignature"><div>Duncan Stuart</div></div></font></span><div class="HOEnZb"><div class="h5">
<br/><div class="gmail_quote"><div dir="ltr">On Wed, 14 Feb 2018 at 09:17 Stuart Harrison <u> </u> <<a href="mailto:Stuart+Harrison+%3Cpezholio@gmail.com%3E" target="_blank">Stuart Harrison <u> </u> <u> </u></a>> wrote:<br/><u> </u></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id="m_-437691239638132493bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Hey LRUG</div>
<div class="m_-437691239638132493bloop_sign" id="m_-437691239638132493bloop_sign_1518599819691031040">
<div id="m_-437691239638132493bloop_customfont" style="margin:0px"><br/></div>
<div id="m_-437691239638132493bloop_customfont" style="margin:0px">I’m about to embark on a project which has a couple of multi page branched forms, and, as it’s a common problem, I’m wondering if something exists that allows me to design a form either via a DSL or YAML, rather than having to reinvent the wheel each time. I used <a href="https://github.com/NUBIC/surveyor" target="_blank">Surveyor</a> a few years ago, which kinda worked for me, but it did cause some pretty major headaches too, and now seems to be largely abandoned. I like the look of <a href="https://github.com/schneems/wicked" target="_blank">Wicked</a>, which gets me part of the way there, but I don’t get that DSL-y way of designing the form and not having to worry about building the individual form parts in a view. Is there anything out there that supports this? Or are there any patterns that anyone else uses that would help this?</div>
<div id="m_-437691239638132493bloop_customfont" style="margin:0px"><br/></div>
<div id="m_-437691239638132493bloop_customfont" style="margin:0px">Hope this makes sense</div>
<div id="m_-437691239638132493bloop_customfont" style="margin:0px"><br/></div>
<div id="m_-437691239638132493bloop_customfont" style="margin:0px">Cheers</div>
<div id="m_-437691239638132493bloop_customfont" style="margin:0px"><br/></div>
<div id="m_-437691239638132493bloop_customfont" style="margin:0px">Stu</div>
<div><br/></div>
</div>
</blockquote></div><br/></div></div></blockquote></div><br/>______________________________<wbr>_________________<br/>
Chat mailing list<br/>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br/>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/<wbr>pipermail/chat-lrug.org</wbr></a><br/>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.<wbr>cgi/chat-lrug.org</wbr></a><br/>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/<wbr>listinfo.cgi/chat-lrug.org</wbr></a><br/>
<br/></wbr></blockquote></div><br/><br clear="all"/><div><br/></div>-- <br/><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p style="font-family:Helvetica,Arial,sans-serif;font-size:14px;line-height:15px;color:rgb(153,153,153)"><span style="font-weight:bold"><br/>Rob Anderson </span><span>CTO</span></p><p style="font-family:Helvetica,Arial,sans-serif;font-size:14px;line-height:15px;color:rgb(153,153,153)"><span style="font-size:12px;font-weight:bold">Payment Card Solutions (UK) Ltd</span><span style="color:rgb(0,0,0);font-size:12px"> </span><br/></p><p style="color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;font-size:12px;line-height:13px"><span style="color:rgb(153,153,153)">3A The Plough Brewery, 516 Wandsworth Road, London SW8 3JX</span><br/><br/><span style="color:rgb(153,153,153)">Office: +44 (0) </span><span style="color:rgb(153,153,153)">20 3137 3422</span> <span style="color:rgb(153,153,153)">| Mob: +44 (0) 7767 623794</span> <br/></p><p style="color:rgb(0,0,0);font-family:Times;font-size:medium"><a href="http://www.paymentcardsolutions.co.uk" title="paymentcardsolutions.co.uk" target="_blank"><img src="http://www.paymentcardsolutions.co.uk/data/PCS_emailsignoff.png" alt="PCS Email Logo" style="padding:15px 15px 5px 0px;border:none;width:702px;height:80px"/></a></p><p style="color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;font-size:2px"><a href="http://www.facebook.com/pages/Bread-for-Business-Prepaid-Card/1453603974852717" target="_blank"><img src="http://htmlsig.com/images/icon-komodo/facebook.png" alt="Facebook"/></a> <a href="http://twitter.com/breadcards" target="_blank"><img src="http://htmlsig.com/images/icon-komodo/twitter-2.png" alt="Twitter"/></a> <a href="http://www.linkedin.com/company/payment-card-solutions-uk-ltd?trk=cp_followed_name_payment-card-solutions-uk-ltd" target="_blank"><img src="http://htmlsig.com/images/icon-komodo/linkedin.png" alt="Linkedin"/></a></p><p style="font-family:Helvetica,Arial,sans-serif;color:rgb(153,153,153);font-size:9px;line-height:10px">This e-mail message may contain confidential or legally privileged information and is intended only for the use of the intended recipient(s). Any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is prohibited. E-mails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, or contain viruses. Anyone who communicates with us by e-mail is deemed to have accepted these risks. Payment Card Solutions (UK) Ltd is not responsible for errors or omissions in this message and denies any responsibility for any damage arising from the use of e-mail. Any opinion and other statement contained in this message and any attachment are solely those of the author and do not necessarily represent those of the company.</p><p style="color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;font-size:2px"> </p></div></div></div></div></div></div>
</div>
<br/>