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

@@ -2,7 +2,9 @@ class ArtistVersionsController < ApplicationController
respond_to :html, :xml, :json
def index
@artist_versions = ArtistVersion.paginated_search(params).includes(model_includes(params))
@artist_versions = ArtistVersion.paginated_search(params)
@artist_versions = @artist_versions.includes(:updater, artist: :urls) if request.format.html?
respond_with(@artist_versions)
end
@@ -12,14 +14,4 @@ class ArtistVersionsController < ApplicationController
format.html { redirect_to artist_versions_path(search: { artist_id: @artist_version.artist_id }) }
end
end
private
def default_includes(params)
if ["json", "xml"].include?(params[:format])
[]
else
[:updater, {artist: [:urls]}]
end
end
end