<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap:break-word;line-break:after-white-space"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Cool, thanks all. That’s really useful. Given me a lot of food for thought. I think I’m going to go down the route of using Wicked and having some DB persistence, as well as using a form object to separate out the branching and validation logic. This still feels like something that could be standardised / gemified, as it’s a common problem, particularly in the public sector (funnily enough, this is actually for some work I’m doing for Hackney Council!). I will continue to mull, but this is super useful.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Cheers</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Stu</div> <br> <div id="bloop_sign_1518613921926669056" class="bloop_sign"></div> <br><p class="airmail_on">On 14 February 2018 at 13:10:45, Murray Steele (<a href="mailto:murray.steele@gmail.com">murray.steele@gmail.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>


<title></title>


<div dir="ltr">I think the <a href="http://gov.uk">gov.uk</a> app
you’re talking about would be smart-answers (<a href="https://github.com/alphagov/smart-answers">https://github.com/alphagov/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">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/">gov.uk/something/y/aberdeen/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">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>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</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</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>
<div id="m_-6325947446639865750psignature">
<div><span class="HOEnZb"><font color="#888888">Duncan
Stuart</font></span></div>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">
<div dir="ltr">On Wed, 14 Feb 2018 at 09:17 Stuart Harrison
<<a href="mailto:Stuart+Harrison+%3Cpezholio@gmail.com%3E" target="_blank">Stuart Harrison</a>> wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id="m_-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_-6325947446639865750bloop_sign" id="m_-6325947446639865750bloop_sign_1518599819691031040">
<div id="m_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-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_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-6325947446639865750bloop_customfont" style="margin:0px">Hope this makes sense</div>
<div id="m_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-6325947446639865750bloop_customfont" style="margin:0px">Cheers</div>
<div id="m_-6325947446639865750bloop_customfont" style="margin:0px"><br></div>
<div id="m_-6325947446639865750bloop_customfont" style="margin:0px">Stu</div>
<div><br></div>
</div>
</blockquote>
</div>
<br></div>
</div>
</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>


_______________________________________________
<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></div></div></span></blockquote></body></html>