Skip to content

Commit

Permalink
Redirect user to same event page after profile creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrik Folkerts committed Dec 8, 2016
1 parent 33a5018 commit 13f2ad4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/application_letters_controller.rb
Expand Up @@ -21,6 +21,8 @@ def new
return redirect_to user_session_path, :alert => message
elsif not current_user.profile.present?
message = I18n.t('application_letters.fill_in_profile_before_creation')
flash[:event_id] = params[:event_id]
flash.keep(:event_id)
return redirect_to new_profile_path, :alert => message
end
@application_letter = ApplicationLetter.new
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/profiles_controller.rb
Expand Up @@ -15,6 +15,7 @@ def show
# GET /profiles/new
def new
@profile = Profile.new
flash.keep(:event_id)
end

# GET /profiles/1/edit
Expand All @@ -27,7 +28,11 @@ def create
@profile.user_id = current_user.id

if @profile.save
redirect_to @profile, notice: 'Profile was successfully created.'
if flash[:event_id]
redirect_to new_application_letter_path(:event_id => flash[:event_id])
else
redirect_to @profile
end
else
render :new
end
Expand Down

0 comments on commit 13f2ad4

Please sign in to comment.