controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -12,7 +12,9 @@ class BansController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@bans = Ban.paginated_search(params, count_pages: true).includes(model_includes(params))
|
||||
@bans = Ban.paginated_search(params, count_pages: true)
|
||||
@bans = @bans.includes(:user, :banner) if request.format.html?
|
||||
|
||||
respond_with(@bans)
|
||||
end
|
||||
|
||||
@@ -48,14 +50,6 @@ class BansController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:user, :banner]
|
||||
end
|
||||
end
|
||||
|
||||
def ban_params(context)
|
||||
permitted_params = %i[reason duration expires_at]
|
||||
permitted_params += %i[user_id user_name] if context == :create
|
||||
|
||||
Reference in New Issue
Block a user