controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -41,20 +41,13 @@ class BulkUpdateRequestsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@bulk_update_requests = BulkUpdateRequest.paginated_search(params, count_pages: true).includes(model_includes(params))
|
||||
@bulk_update_requests = BulkUpdateRequest.paginated_search(params, count_pages: true)
|
||||
@bulk_update_requests = @bulk_update_requests.includes(:user, :approver, :forum_topic, forum_post: [:votes]) if request.format.html?
|
||||
respond_with(@bulk_update_requests)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:user, :approver, :forum_topic, {forum_post: [:votes]}]
|
||||
end
|
||||
end
|
||||
|
||||
def load_bulk_update_request
|
||||
@bulk_update_request = BulkUpdateRequest.find(params[:id])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user