Hello, I'm working to create a method in my controller to check an
email to see if the email's domain is acceptable. I want to prevent
gmail and hotmail for certain reasons. Here's what I have so far:
controller:
if valid_email_domain(email_address)
# good email domain
else
# bad email domain
end
protected
def valid_email_domain(emailAddy)
reg = Regexp.new '/#{User::INVALID_EMAILS.map{|a|
Regexp.quote(a)}.join("|")}/'
return true if emailAddy.scan(reg).size == 0
end
user model:
INVALID_EMAILS = %w(gmail.com hotmail.com)
But that errors, any ideas? I'm not sure if I'm doing the REGEX
correctly, could use some regex help.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.