reject email addresses with spaces, catch mailer delivery errors
This commit is contained in:
parent
1987a24a2a
commit
f0bc4e7c8d
|
@ -6,11 +6,16 @@ class InvitationsController < ApplicationController
|
|||
i.user_id = @user.id
|
||||
i.email = params[:email]
|
||||
i.memo = params[:memo]
|
||||
if i.save
|
||||
i.send_email
|
||||
flash[:success] = "Successfully e-mailed invitation to " <<
|
||||
params[:email].to_s << "."
|
||||
else
|
||||
|
||||
begin
|
||||
if i.save
|
||||
i.send_email
|
||||
flash[:success] = "Successfully e-mailed invitation to " <<
|
||||
params[:email].to_s << "."
|
||||
else
|
||||
raise
|
||||
end
|
||||
rescue
|
||||
flash[:error] = "Could not send invitation, verify the e-mail " <<
|
||||
"address is valid."
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class Invitation < ActiveRecord::Base
|
|||
attr_accessible nil
|
||||
|
||||
validate do
|
||||
if !email.to_s.match(/\A[^@]+@[^@]+\.[^@]+\z/)
|
||||
if !email.to_s.match(/\A[^@ ]+@[^ @]+\.[^ @]+\z/)
|
||||
errors.add(:email, "is not valid")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue