From c35270ad315de5455dc4446144694906a6e70e5b Mon Sep 17 00:00:00 2001 From: Aditya Prakash Date: Thu, 31 Mar 2016 15:31:54 +0530 Subject: [PATCH] More sane branching in confirm action of proposal controller --- app/controllers/proposal_controller.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index c66c0d8c..ae8d82aa 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -110,18 +110,17 @@ class ProposalController < ApplicationController return end - unless @event.save + if @event.save + if @conference.user_registered?(current_user) + redirect_to conference_program_proposal_index_path(@conference.short_title), + notice: 'The proposal was confirmed.' + else + redirect_to new_conference_conference_registrations_path(conference_id: @conference.short_title), + alert: 'The proposal was confirmed. Please register to attend the conference.' + end + else redirect_to conference_program_proposal_index_path(conference_id: @conference.short_title), error: "Could not confirm proposal: #{@event.errors.full_messages.join(', ')}" - return - end - - if @conference.user_registered?(current_user) - redirect_to conference_program_proposal_index_path(@conference.short_title), - notice: 'The proposal was confirmed.' - else - redirect_to new_conference_conference_registrations_path(conference_id: @conference.short_title), - alert: 'The proposal was confirmed. Please register to attend the conference.' end end