J
Joe Peck
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,
assword
validates_uniqueness_of :email
validates_format_of :email,
:with => %r{\.(edu|com)$}i,
:message => "Must be a valid email address"
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,
validates_uniqueness_of :email
validates_format_of :email,
:with => %r{\.(edu|com)$}i,
:message => "Must be a valid email address"