What is the best/easy way to validate an email address in Ruby?

You could look whether or not it matches a regexp like the one used in this Rails validator:

validates_format_of :email,:with => /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/

But if you use Devise, simply do:

validates_format_of :email,:with => Devise::email_regexp

Source: http://lindsaar.net/2008/4/14/tip-4-detecting-a-valid-email-address

Edit 1:

useful website for tests: http://www.rubular.com/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)