Forum: Ruby on Rails Soft Validation

E2320db259309669daf300125736c5c2?d=identicon&s=25 Michael Roess (Guest)
on 2014-04-14 22:59
(Received via mailing list)
Hi,

I'm a new-ish part time rails dev, self taught, so I apologize if this
is a
question that I should know the answer to.  I've had no luck finding a
way
to implement soft validations in rails (i.e. the form will give you a
warning that certain fields are not right and an option to go back an
correct them or to submit the incorrect information).

We have a demographics form that asks for sensitive information--so we
would like to let people know if they simply skipped a question
accidentally, but permits them to submit the form without having
answered
all of the questions should they prefer.  In case it matters--we're only
looking at radio buttons and check boxes, and we're only checking to see
if
the questions were answered.

The only thing I was able to find was a rubyforge gem abandoned over six
years ago.

Does anyone know if there is any way to do this with rails?

Thanks for any help!

Mike
A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2014-04-15 01:25
(Received via mailing list)
On Apr 14, 2014, at 3:30 PM, Michael Roess wrote:

> Hi,
>
> I'm a new-ish part time rails dev, self taught, so I apologize if this is a
question that I should know the answer to.  I've had no luck finding a way to
implement soft validations in rails (i.e. the form will give you a warning that
certain fields are not right and an option to go back an correct them or to 
submit
the incorrect information).
>
> We have a demographics form that asks for sensitive information--so we would
like to let people know if they simply skipped a question accidentally, but
permits them to submit the form without having answered all of the questions
should they prefer.  In case it matters--we're only looking at radio buttons and
check boxes, and we're only checking to see if the questions were answered.
>
> The only thing I was able to find was a rubyforge gem abandoned over six years
ago.
>
> Does anyone know if there is any way to do this with rails?

If you do these optional validations with JavaScript, then they can be
independent of the business rules that Rails enforces (the ones that
absolutely stop submission). That might be a way to get around this
issue.

Walter
Ec2c1a36301b0223c3e281bd2ec3f37a?d=identicon&s=25 Dave Aronson (Guest)
on 2014-04-15 14:03
(Received via mailing list)
On Mon, Apr 14, 2014 at 3:30 PM, Michael Roess <mike.roess@gmail.com>
wrote:

> we would
> like to let people know if they simply skipped a question accidentally, but
> permits them to submit the form without having answered all of the questions
> should they prefer.

Not Rails-specific, but: why not simply allow "prefer not to answer"
as an option?  That way, you can easily enforce that they must give
*some* kind of response to all questions, but they don't have to
reveal personal info if they don't want to.

--
Dave Aronson, freelance software developer (details @ www.Codosaur.us);
see also www.PullRequestRoulette.com, Blog.Codosaur.us, www.Dare2XL.com
37905ed02240846d5845881a0996f8ea?d=identicon&s=25 Maximilian Busch (Guest)
on 2014-04-15 15:03
(Received via mailing list)
Hi Mike,

it seems like you want to do some validation to improve the user
experience, give them some feedback etc.

Without knowing the exact use cases I would go with a combination of
client- and server-side validation. On client's side you can go with one
of
the various jQuery form validation plugins that suits your needs. On the
other hand it's not that big of a deal to write some custom JavaScript
to
check for some basic things, like completion of questions etc.

But I would like to stress the point that you definitely should validate
the most important things on the server-side (validation in models,
see http://guides.rubyonrails.org/active_record_validations.html). To be
absolutely sure, you should check the rules on client-side again on
server
side.

Good luck!
Max

Am Montag, 14. April 2014 21:30:51 UTC+2 schrieb Michael Roess:
E2320db259309669daf300125736c5c2?d=identicon&s=25 Michael Roess (Guest)
on 2014-04-15 20:07
(Received via mailing list)
Hi all,

Thanks for the suggestions.  I was hoping to avoid client-side
validations
just because it means replicating a lot of work already done (and my
JS/JQuery is not up to snuff, but I should take it as an opportunity to
work on that).  That will be the route I take, I guess.

Dave: the 'I prefer not to answer' is the best option if we assume
humans
act rationally.  However, if you state that as an option many people
assume
there is some reason that they should not answer and they not only
choose
not to answer but become more suspicious and tend to drop out of the
study.  Also, if personal experience is generalizable, many people are
lazy
and will just click that if they don't to look up an answer.  For these
reasons we'd like to avoid cluing them in to the fact that they can skip
the question, but we want to let them skip it if they have an actual
objection to providing the information.

Max: Yes, I plan to keep the server side validations in check for
everything important.  These question pertain mostly to demographic
information--household income and the like--that people may have
objections
to sharing, and that won't destroy our data if they're absent--just
present
a less rich picture.

Once again, thanks all for the feedback.  It's encouraging as to someone
starting freelance work.

Mike
1e4bc344d2e910ab8bbaf3fa37838e55?d=identicon&s=25 BuyzLots (Guest)
on 2014-04-15 20:32
(Received via mailing list)
You might be able to utilize html5 validation, all depends on the
requirements. http://diveintohtml5.info/forms.html#validation
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.