controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -2,17 +2,9 @@ class DtextLinksController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def index
|
||||
@dtext_links = DtextLink.paginated_search(params).includes(model_includes(params))
|
||||
@dtext_links = DtextLink.paginated_search(params)
|
||||
@dtext_links = @dtext_links.includes(:model) if request.format.html?
|
||||
|
||||
respond_with(@dtext_links)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:model]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user