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 ModActionsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def index
|
||||
@mod_actions = ModAction.paginated_search(params).includes(model_includes(params))
|
||||
@mod_actions = ModAction.paginated_search(params)
|
||||
@mod_actions = @mod_actions.includes(:creator) if request.format.html?
|
||||
|
||||
respond_with(@mod_actions)
|
||||
end
|
||||
|
||||
@@ -12,14 +14,4 @@ class ModActionsController < ApplicationController
|
||||
fmt.html { redirect_to mod_actions_path(search: { id: @mod_action.id }) }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:creator]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user