Have single result searches go to the show pages for certain controllers #4204

This commit is contained in:
evazion
2019-11-04 14:24:10 -06:00
parent 953de62d70
commit 6e5e07022d
6 changed files with 25 additions and 14 deletions

View File

@@ -37,14 +37,12 @@ class ArtistsController < ApplicationController
end
def index
@artists = Artist.includes(:urls).search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
respond_with(@artists) do |format|
format.xml do
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
end
format.json do
render :json => @artists.to_json(:include => [:urls])
end
@artists = Artist.includes(:urls).paginated_search(params)
if params[:redirect].to_s.truthy? && @artists.one? && @artists.first.name == Artist.normalize_name(params[:search][:any_name_or_url_matches])
redirect_to @artists.first
else
respond_with @artists
end
end