Permalink
Browse files

don't create new record when blank email submitted

  • Loading branch information...
1 parent ee22aa6 commit b32ccb9a04fb43200f2bf43b753379f261d0d430 @alphabetum committed Oct 7, 2010
Showing with 8 additions and 6 deletions.
  1. +8 −6 landing_page.rb
View
@@ -28,12 +28,14 @@
post '/notify' do
email = params[:email]
- port = 27089 # port from mongohq
- db = Mongo::Connection.new("mongohq-url", port).db("database")
- auth = db.authenticate("username", "password")
- coll = db.collection("emails")
- doc = {"email" => email}
- coll.insert(doc)
+ unless email.nil? || email.strip.empty?
+ port = 27089 # port from mongohq
+ db = Mongo::Connection.new("mongohq-url", port).db("database")
+ auth = db.authenticate("username", "password")
+ coll = db.collection("emails")
+ doc = {"email" => email}
+ coll.insert(doc)
+ end
if request.xhr?
"true"
else

0 comments on commit b32ccb9

Please sign in to comment.