Add flash type error.Rewrite controllers to use common flash style with redirect_to

This commit is contained in:
Nishanth Vijayan 2016-03-10 14:25:38 +05:30
parent dcdceb7c6d
commit 434eb90b76
16 changed files with 81 additions and 85 deletions

View file

@ -60,11 +60,12 @@ class ConferenceRegistrationsController < ApplicationController
sign_in(@registration.user)
end
flash[:notice] = 'You are now registered and will be receiving E-Mail notifications.'
if @conference.tickets.any? && !current_user.supports?(@conference)
redirect_to conference_tickets_path(@conference.short_title)
redirect_to conference_tickets_path(@conference.short_title),
notice: 'You are now registered and will be receiving E-Mail notifications.'
else
redirect_to conference_conference_registrations_path(@conference.short_title)
redirect_to conference_conference_registrations_path(@conference.short_title),
notice: 'You are now registered and will be receiving E-Mail notifications.'
end
else
flash[:error] = "Could not create your registration for #{@conference.title}: "\
@ -100,8 +101,8 @@ class ConferenceRegistrationsController < ApplicationController
def set_registration
@registration = Registration.find_by(conference: @conference, user: current_user)
if !@registration
flash[:alert] = "Can't find a registration for #{@conference.title} for you. Please register."
redirect_to new_conference_conference_registrations_path(@conference.short_title)
redirect_to new_conference_conference_registrations_path(@conference.short_title),
alert: "Can't find a registration for #{@conference.title} for you. Please register."
end
end