<div dir="ltr">Hi Murray - I looked it up: it was the <a href="http://gov.uk">gov.uk</a> Verify frontend: <a href="https://github.com/alphagov/verify-frontend">https://github.com/alphagov/verify-frontend</a><br><br>Answers are stored in the session, not the URL: <a href="https://github.com/alphagov/verify-frontend/blob/d3e1444ce7658bce353f85b2ece4d101666be3ef/app/models/selected_answer_store.rb">https://github.com/alphagov/verify-frontend/blob/d3e1444ce7658bce353f85b2ece4d101666be3ef/app/models/selected_answer_store.rb</a><br><br>In their case the forms are all very small and they seem to do any required validation in the controller. We took the same approach as Andrew and had individual form objects for each page.<br><br>Cheers<br><br>Duncan</div><div class="gmail_extra"><br><div class="gmail_quote">On 14 February 2018 at 13:10, Murray Steele <span dir="ltr"><<a href="mailto:murray.steele@gmail.com" target="_blank">murray.steele@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think the <a href="http://gov.uk" target="_blank">gov.uk</a> app you’re talking about would be smart-answers (<a href="https://github.com/alphagov/smart-answers" target="_blank">https://github.com/alphagov/<wbr>smart-answers</a>).  This avoids most of the problems by encoding all the answers in the url.  E.g. you start at <a href="http://gov.uk/something" target="_blank">gov.uk/something</a> and then advance through some questions until you get to something like <a href="http://gov.uk/something/y/aberdeen/1000/dogs/n/n/2018/" target="_blank">gov.uk/something/y/aberdeen/<wbr>1000/dogs/n/n/2018/</a>  which has your outcome.  I reckon this is a reasonable approach if you can encode the answers in the URL, and you’re not exposing any personally identifiable information by doing so.<div><br></div><div>I’ve also used the approach Rob suggests of hiding all the previous state in hidden fields in the form, and using some logic on the backend to work out what the next step is.  Ultimately this means that your final step is a standard rails create action with a big hash of params that you persist to the db in an active record object.  I think this works ok, but it may depend how complicated your step-by-step form is, and if there’s any branching or whatever.  I didn’t use a gem for this, just rolled my own thing.</div><div><br></div><div>The advantage of something like Wicked though is that you persist in the db at various stages and can get some after-the-fact analytics on abandoned sessions and how far through people get which might help you tweak the form to simplify it.  Or you can also email people a week later to say “Hey, you didn’t finish this thing, can we help / give you a discount / whatever” which may be useful.</div><div><br></div><div>Cheers,</div><div><br></div><div>Murray</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">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></span><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 class="h5"><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/LB<wbr>Hackney-IT/maintain-my-home/bl<wbr>ob/develop/app/models/selected<wbr>_answer_store.rb</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/LBHac<wbr>kney-IT/maintain-my-home/blob/<wbr>develop/app/models/question_<wbr>set.rb</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="m_-5092768324201762573HOEnZb"><font color="#888888"><br><br>
</font></span></div><span class="m_-5092768324201762573HOEnZb"><font color="#888888">
<div id="m_-5092768324201762573m_-6325947446639865750psignature"><div>Duncan Stuart</div></div></font></span><div class="m_-5092768324201762573HOEnZb"><div class="m_-5092768324201762573h5">
<div class="gmail_extra"><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_-5092768324201762573m_-6325947446639865750bloop_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_-5092768324201762573m_-6325947446639865750bloop_sign" id="m_-5092768324201762573m_-6325947446639865750bloop_sign_1518599819691031040">
<div id="m_-5092768324201762573m_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-5092768324201762573m_-6325947446639865750bloop_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_-5092768324201762573m_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-5092768324201762573m_-6325947446639865750bloop_customfont" style="margin:0px">Hope this makes sense</div>
<div id="m_-5092768324201762573m_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-5092768324201762573m_-6325947446639865750bloop_customfont" style="margin:0px">Cheers</div>
<div id="m_-5092768324201762573m_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-5092768324201762573m_-6325947446639865750bloop_customfont" style="margin:0px">Stu</div>
<div><br></div>
</div>

</blockquote></div><br></div></div></div><br></div></div><span class="">______________________________<wbr>_________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">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/pipermai<wbr>l/chat-lrug.org</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</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo<wbr>.cgi/chat-lrug.org</a><br>
<br></span></blockquote></div><br></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</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</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</a><br>
<br></blockquote></div><br></div>