controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -6,7 +6,9 @@ class NotesController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@notes = Note.paginated_search(params).includes(model_includes(params))
|
||||
@notes = Note.paginated_search(params)
|
||||
@notes = @notes.includes(:creator, :post) if request.format.html?
|
||||
|
||||
respond_with(@notes)
|
||||
end
|
||||
|
||||
@@ -59,14 +61,6 @@ class NotesController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:creator, :post]
|
||||
end
|
||||
end
|
||||
|
||||
def note_params(context)
|
||||
permitted_params = %i[x y width height body]
|
||||
permitted_params += %i[post_id html_id] if context == :create
|
||||
|
||||
Reference in New Issue
Block a user