controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -10,7 +10,9 @@ class ModerationReportsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@moderation_reports = ModerationReport.paginated_search(params, count_pages: true).includes(model_includes(params))
|
||||
@moderation_reports = ModerationReport.paginated_search(params, count_pages: true)
|
||||
@moderation_reports = @moderation_reports.includes(:creator, :model) if request.format.html?
|
||||
|
||||
respond_with(@moderation_reports)
|
||||
end
|
||||
|
||||
@@ -29,14 +31,6 @@ class ModerationReportsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:creator, :model]
|
||||
end
|
||||
end
|
||||
|
||||
def model_type
|
||||
params.fetch(:moderation_report, {}).fetch(:model_type)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user