Using guard clause instead of conditional wrapping

Signed-off-by: Carlos Coelho <carlos@pencillabs.com>
This commit is contained in:
Carlos Coelho 2016-03-04 11:34:16 -03:00
parent 2302821c48
commit aa912357d6

View file

@ -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