From 44653fb72282ead81369e0835e6f48d8fdde628e Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 21 Aug 2019 23:57:12 -0500 Subject: [PATCH] Fix errors on /artists/show_or_new, /wiki_pages/show_or_new pages. Fix these pages to redirect to the new page instead of erroring out when a name or title isn't given. --- app/controllers/artists_controller.rb | 5 ++++- app/controllers/wiki_pages_controller.rb | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 10f240af9..afe8d3afd 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -83,7 +83,10 @@ class ArtistsController < ApplicationController def show_or_new @artist = Artist.find_by_name(params[:name]) - if @artist + + if params[:name].blank? + redirect_to new_artist_path(artist_params(:new)) + elsif @artist.present? redirect_to artist_path(@artist) else @artist = Artist.new(name: params[:name]) diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index a06091ff7..142c8deef 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -82,7 +82,10 @@ class WikiPagesController < ApplicationController def show_or_new @wiki_page = WikiPage.find_by_title(params[:title]) - if @wiki_page + + if params[:title].blank? + redirect_to new_wiki_page_path(wiki_page_params(:create)) + elsif @wiki_page.present? redirect_to wiki_page_path(@wiki_page) else @wiki_page = WikiPage.new(:title => params[:title])