controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -4,7 +4,9 @@ class PoolVersionsController < ApplicationController
|
||||
around_action :set_timeout
|
||||
|
||||
def index
|
||||
@pool_versions = PoolArchive.paginated_search(params).includes(model_includes(params))
|
||||
@pool_versions = PoolArchive.paginated_search(params)
|
||||
@pool_versions = @pool_versions.includes(:updater, :pool) if request.format.html?
|
||||
|
||||
respond_with(@pool_versions)
|
||||
end
|
||||
|
||||
@@ -27,14 +29,6 @@ class PoolVersionsController < ApplicationController
|
||||
"PoolArchive"
|
||||
end
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:updater, :pool]
|
||||
end
|
||||
end
|
||||
|
||||
def set_timeout
|
||||
PoolArchive.connection.execute("SET statement_timeout = #{CurrentUser.user.statement_timeout}")
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user