From aa912357d635a67321388952cba1c3cbc3f121b5 Mon Sep 17 00:00:00 2001 From: Carlos Coelho Date: Fri, 4 Mar 2016 11:34:16 -0300 Subject: [PATCH] Using guard clause instead of conditional wrapping Signed-off-by: Carlos Coelho --- app/controllers/proposal_controller.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index c3e16e36..18e62098 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -148,11 +148,9 @@ class ProposalController < ApplicationController @event.event_users.new(user: current_user, event_role: 'speaker') - unless @event.save - flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'new' - return - end + return unless !@event.save + flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" + render action: 'new' end end