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

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