summaryrefslogtreecommitdiffstats
path: root/registration.rb
diff options
context:
space:
mode:
Diffstat (limited to 'registration.rb')
-rw-r--r--registration.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/registration.rb b/registration.rb
index e5be8f0..c6598d1 100644
--- a/registration.rb
+++ b/registration.rb
@@ -1,9 +1,14 @@
require 'sinatra/base'
+require 'sinatra/url_for'
require_relative 'lib/registration'
class RegistrationApp < Sinatra::Base
+ helpers Sinatra::UrlForHelper
+ include ERB::Util
get '/' do
+ @errors = request['errors']
+ @errors = @errors.split('|') if @errors
erb :index
end
@@ -11,9 +16,13 @@ class RegistrationApp < Sinatra::Base
if request.form_data?
#p request['band']
@band = Band.new(request['band'])
- generate_pdf_for @band
- send_registration_emails_for @band
- erb :submitted
+ if @band.valid?
+ generate_pdf_for @band
+ send_registration_emails_for @band
+ erb :submitted
+ else
+ redirect to(url_for('/', :errors => @band.errors.join('|')))
+ end
end
end