summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRosemary Sanchez <rsanchez@madebyuppercut.com>2013-07-19 15:16:11 -0600
committerRosemary Sanchez <rsanchez@madebyuppercut.com>2013-07-19 15:16:11 -0600
commitc2156d0da03d5a2fb6383c1a1ad411a2de230e9b (patch)
tree5eb1f82b7840f45155bfca9b4c0d751ba0b14130
parent1762497db42118c77c7737522fe931cd91bb4af8 (diff)
Sign up model now with email validation.
-rw-r--r--app/controllers/sign_ups_controller.rb2
-rw-r--r--app/models/sign_up.rb4
2 files changed, 6 insertions, 0 deletions
diff --git a/app/controllers/sign_ups_controller.rb b/app/controllers/sign_ups_controller.rb
index 7b03639..fd053f9 100644
--- a/app/controllers/sign_ups_controller.rb
+++ b/app/controllers/sign_ups_controller.rb
@@ -8,6 +8,8 @@ class SignUpsController < ApplicationController
if @sign_up.save
redirect_to @sign_up
+ else
+ render action: "new"
end
end
diff --git a/app/models/sign_up.rb b/app/models/sign_up.rb
index a3c400e..65c2eb2 100644
--- a/app/models/sign_up.rb
+++ b/app/models/sign_up.rb
@@ -1,2 +1,6 @@
class SignUp < ActiveRecord::Base
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
+ validates :email, presence: true,
+ format: { with: VALID_EMAIL_REGEX },
+ uniqueness: { case_sensitive: false }
end