devise validatable and password_confirmation presence

51 views
Skip to first unread message

enrico stano

unread,
Sep 28, 2012, 1:14:37 PM9/28/12
to rubyonra...@googlegroups.com
Hi,

I was writing some tests when I discovered (god bless testing...) that my User model, that use Devise, doesn't validate the presence of the :password_confirmation field.

I was expecting that adding :validatable to the Devise option would include the presence validation for this field too.

Could any one please explain this behaviour?

There is a better solution than simply adding that field to User model validation?

thank you.

bye,

enricostn

Norbert Melzer

unread,
Sep 28, 2012, 3:39:18 PM9/28/12
to rubyonra...@googlegroups.com
Can't follow you… all the confirmation-fields you probably have, don't
need to be checked if they are present… That's throwing away CPU
cycles and therefore money!

It is simple logic:

When all validations pass on the original field they will also pass on
the corresponding confirmation field, as long as it has the same value
as the original field. So do all necessary validations on your
original field, check if it is identical with the confirmation field
and you are done…

2012/9/28 enrico stano <enri...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/J_r2Hs92FgsJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

enrico stano

unread,
Sep 28, 2012, 3:45:14 PM9/28/12
to rubyonra...@googlegroups.com
Ok I got it. You're probably right. The validation for the
confirmation field it's related to the comparation with the original
field.

Thanks

2012/9/28 Norbert Melzer <timm...@gmail.com>:
--
· Enrico Stano
·
· twitter @enricostano
· skype ocirneonats
Reply all
Reply to author
Forward
0 new messages