controllers: refactor only param includes.

Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
evazion
2020-02-14 20:08:42 -06:00
parent 8649ff6dbe
commit 2564e885c8
42 changed files with 153 additions and 387 deletions

View File

@@ -23,7 +23,9 @@ class UploadsController < ApplicationController
end
def index
@uploads = Upload.paginated_search(params, count_pages: true).includes(model_includes(params))
@uploads = Upload.paginated_search(params, count_pages: true)
@uploads = @uploads.includes(:uploader, post: :uploader) if request.format.html?
respond_with(@uploads)
end
@@ -58,14 +60,6 @@ class UploadsController < ApplicationController
private
def default_includes(params)
if ["json", "xml"].include?(params[:format])
[]
else
[:uploader, {post: [:uploader]}]
end
end
def upload_params
permitted_params = %i[
file source tag_string rating status parent_id artist_commentary_title