controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -2,7 +2,9 @@ class ArtistCommentaryVersionsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def index
|
||||
@commentary_versions = ArtistCommentaryVersion.paginated_search(params).includes(model_includes(params))
|
||||
@commentary_versions = ArtistCommentaryVersion.paginated_search(params)
|
||||
@commentary_versions = @commentary_versions.includes(:updater, post: :uploader) if request.format.html?
|
||||
|
||||
respond_with(@commentary_versions)
|
||||
end
|
||||
|
||||
@@ -12,14 +14,4 @@ class ArtistCommentaryVersionsController < ApplicationController
|
||||
format.html { redirect_to artist_commentary_versions_path(search: { post_id: @commentary_version.post_id }) }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[{post: [:uploader]}, :updater]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user