CuriousNewbie wrote in post #976445:
> 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?

And the error you get is...?

> I'm not sure if I'm doing the REGEX
> correctly, could use some regex help.

Well, your regex seems OK, but you should be doing your validation in 
the model, not the controller.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

-- 
Posted via http://www.ruby-forum.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 [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.

Reply via email to