I want to do this:
validates_format_of :email, :with => email_regex
def email_regex
email_name_regex = '[A-Z0-9_\.%\+\-]+'
domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
return /\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i
end
but I am getting an error saying that I have to pass a regex to the validates method. I was sure youo could do something like this. Am I missing a step?
Thanks