Have single result searches go to the show pages for certain controllers #4204
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -18,7 +18,12 @@ class PoolsController < ApplicationController
|
||||
|
||||
def index
|
||||
@pools = Pool.includes(:creator).paginated_search(params, count_pages: true)
|
||||
respond_with(@pools)
|
||||
|
||||
if params[:redirect].to_s.truthy? && @pools.one? && Pool.normalize_name_for_search(@pools.first.name) == Pool.normalize_name_for_search(params[:search][:name_matches])
|
||||
redirect_to @pools.first
|
||||
else
|
||||
respond_with @pools
|
||||
end
|
||||
end
|
||||
|
||||
def gallery
|
||||
|
||||
@@ -28,9 +28,14 @@ class UsersController < ApplicationController
|
||||
if params[:name].present?
|
||||
@user = User.find_by_name!(params[:name])
|
||||
redirect_to user_path(@user)
|
||||
return
|
||||
end
|
||||
|
||||
@users = User.paginated_search(params)
|
||||
if params[:redirect].to_s.truthy? && @users.one? && User.normalize_name(@users.first.name) == User.normalize_name(params[:search][:name_matches])
|
||||
redirect_to @users.first
|
||||
else
|
||||
@users = User.paginated_search(params)
|
||||
respond_with(@users)
|
||||
respond_with @users
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class WikiPagesController < ApplicationController
|
||||
def index
|
||||
@wiki_pages = WikiPage.paginated_search(params)
|
||||
|
||||
if params[:redirect].to_s.truthy? && @wiki_pages.one?
|
||||
if params[:redirect].to_s.truthy? && @wiki_pages.one? && @wiki_pages.first.title == WikiPage.normalize_title(params[:search][:title])
|
||||
redirect_to @wiki_pages.first
|
||||
else
|
||||
respond_with(@wiki_pages)
|
||||
|
||||
Reference in New Issue
Block a user