Hi Hoboers,
I'm trying to add a function to my user model that validates the email
address they are signing up with ends in a certain domain. I've added
two things to my model...
1. A function for the actual validation:
def validate_internal_email(email)
domain = email.match(/\@(.+)/)[1] # isolate the domain out of
address
return true if domain.to_s == "hq.example.com"
return false
end
2. A before_create check to run the validation: (Not sure this is the
right approach for what I'm trying to do)
before_create do |user|
if validate_internal_email(:email_address) == false
error-messages.add("Your email must end in hq.example.com")
end
end
Basically the idea is that only users with an
@mysubdomain.mydomain.com can register for an account. Any tips on how
to set this up?
Thanks,
Jake
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en.