Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
??Conditional validation skipping??
Joe Peck
11/30/2007 9:16:00 PM
Hey,
I have validation that I need to be able to bypass depending on a cookie
that the user might have.
My problem is for most users, they have to have a .edu or .com email
address. So I wrote that into the validation.
But if a certain cookie is set, I want to allow them to register with
any email address, and still run the other validations (uniqueness of
email, etc.)
Does anyone have any information on how to do this?
USER MODEL
validates_presence_of :first_name, :last_name, :email, :password
validates_uniqueness_of :email
validates_format_of :email,
:with => %r{\.(edu|com)$}i,
:message => "Must be a valid email address"
--
Posted via
http://www.ruby-...
.
1 Answer
Alex LeDonne
11/30/2007 9:40:00 PM
0
On Nov 30, 2007 4:15 PM, Joe Peck <joe@notsleepy.com> wrote:
> Hey,
>
> I have validation that I need to be able to bypass depending on a cookie
> that the user might have.
>
> My problem is for most users, they have to have a .edu or .com email
> address. So I wrote that into the validation.
>
> But if a certain cookie is set, I want to allow them to register with
> any email address, and still run the other validations (uniqueness of
> email, etc.)
>
> Does anyone have any information on how to do this?
>
> USER MODEL
> validates_presence_of :first_name, :last_name, :email, :password
> validates_uniqueness_of :email
> validates_format_of :email,
> :with => %r{\.(edu|com)$}i,
> :message => "Must be a valid email address"
Maybe use a filter in the controller that does registration. Try the
rails list for more help:
http://groups.google.com/group/rubyon...
or
http://www.ruby-forum.c...
on ruby-forum.
-A
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
??Conditional validation skipping??
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password