controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -4,7 +4,9 @@ class FavoriteGroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
params[:search][:creator_id] ||= params[:user_id]
|
||||
@favorite_groups = FavoriteGroup.paginated_search(params).includes(model_includes(params))
|
||||
@favorite_groups = FavoriteGroup.paginated_search(params)
|
||||
@favorite_groups = @favorite_groups.includes(:creator) if request.format.html?
|
||||
|
||||
respond_with(@favorite_groups)
|
||||
end
|
||||
|
||||
@@ -61,14 +63,6 @@ class FavoriteGroupsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:creator]
|
||||
end
|
||||
end
|
||||
|
||||
def check_write_privilege(favgroup)
|
||||
raise User::PrivilegeError unless favgroup.editable_by?(CurrentUser.user)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user