Hey everyone,
Whats the best way to nest model validations so multple errors relating to
the same field appear one by one, rather than all at once? I was talking
with some people on IRC the other day, but two of the ideas I got appear to
be things that would be nice to have in RoR, but arn''t right now (the
ability to add blocks or if statments, like follows)
validates_presence_of :email do
validates_format_of :email, :with =>
/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/
end
OR
if validates_presence_of :email
validates_format_of :email, :with =>
/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/
end
Neither of these work however, and rather than going into lots of :if => and
functions checking if other variables are set and such, I was wondering if
anyone knew or a gem, plugin, or RoR function to assit with this. Your help
is much appreciated.
--
Regards
Kieran
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---