controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -3,7 +3,9 @@ class ArtistCommentariesController < ApplicationController
|
||||
before_action :member_only, only: [:create_or_update, :revert]
|
||||
|
||||
def index
|
||||
@commentaries = ArtistCommentary.paginated_search(params).includes(model_includes(params))
|
||||
@commentaries = ArtistCommentary.paginated_search(params)
|
||||
@commentaries = @commentaries.includes(post: :uploader) if request.format.html?
|
||||
|
||||
respond_with(@commentaries)
|
||||
end
|
||||
|
||||
@@ -36,14 +38,6 @@ class ArtistCommentariesController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[{post: [:uploader]}]
|
||||
end
|
||||
end
|
||||
|
||||
def commentary_params
|
||||
params.fetch(:artist_commentary, {}).except(:post_id).permit(%i[
|
||||
original_description original_title translated_description translated_title
|
||||
|
||||
Reference in New Issue
Block a user