controllers: refactor only param includes.

Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
evazion
2020-02-14 20:08:42 -06:00
parent 8649ff6dbe
commit 2564e885c8
42 changed files with 153 additions and 387 deletions

View File

@@ -31,7 +31,9 @@ class UsersController < ApplicationController
return
end
@users = User.paginated_search(params).includes(model_includes(params))
@users = User.paginated_search(params)
@users = @users.includes(:inviter) if request.format.html?
respond_with(@users)
end
@@ -94,14 +96,6 @@ class UsersController < ApplicationController
private
def default_includes(params)
if ["json", "xml"].include?(params[:format])
[]
else
[:inviter]
end
end
def item_matches_params(user)
if params[:search][:name_matches]
User.normalize_name(user.name) == User.normalize_name(params[:search][:name_matches])