diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-10-05 20:13:33 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-10-05 20:13:33 +0200 |
commit | 01987cc0b88fdb0748d8d71cca4f5e40ea8a2604 (patch) | |
tree | 4e24583b5a111f718a342df59fba62ccf439f4f2 /registration.rb | |
parent | 696be9ff4d6a6f7e3286cba14df4e4f449d31bb6 (diff) | |
download | norsk-urskog-registrations-01987cc0b88fdb0748d8d71cca4f5e40ea8a2604.tar.gz norsk-urskog-registrations-01987cc0b88fdb0748d8d71cca4f5e40ea8a2604.tar.bz2 norsk-urskog-registrations-01987cc0b88fdb0748d8d71cca4f5e40ea8a2604.zip |
Redirect back to form and display error if no songs specified.
Diffstat (limited to 'registration.rb')
-rw-r--r-- | registration.rb | 15 |
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 |