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 ForumPostVotesController < ApplicationController
|
||||
before_action :member_only, only: [:create, :destroy]
|
||||
|
||||
def index
|
||||
@forum_post_votes = ForumPostVote.paginated_search(params, count_pages: true).includes(model_includes(params))
|
||||
@forum_post_votes = ForumPostVote.paginated_search(params, count_pages: true)
|
||||
@forum_post_votes = @forum_post_votes.includes(:creator, forum_post: [:creator, :topic]) if request.format.html?
|
||||
|
||||
respond_with(@forum_post_votes)
|
||||
end
|
||||
|
||||
@@ -21,14 +23,6 @@ class ForumPostVotesController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:creator, {forum_post: [:topic]}]
|
||||
end
|
||||
end
|
||||
|
||||
def forum_post_vote_params
|
||||
params.fetch(:forum_post_vote, {}).permit(:score)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user