Added universal redirect on the index action
- Only controllers with show actions will redirect on the index action - Parameter checking is individualized per controller for the redirect check
This commit is contained in:
@@ -19,11 +19,7 @@ class PoolsController < ApplicationController
|
||||
def index
|
||||
@pools = Pool.includes(:creator).paginated_search(params, count_pages: true)
|
||||
|
||||
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
|
||||
respond_with(@pools)
|
||||
end
|
||||
|
||||
def gallery
|
||||
@@ -94,6 +90,14 @@ class PoolsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def item_matches_params(pool)
|
||||
if params[:search][:name_matches]
|
||||
Pool.normalize_name_for_search(pool.name) == Pool.normalize_name_for_search(params[:search][:name_matches])
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def pool_params
|
||||
permitted_params = %i[name description category post_ids post_ids_string]
|
||||
params.require(:pool).permit(*permitted_params, post_ids: [])
|
||||
|
||||
Reference in New Issue
Block a user