Add way for controllers with different models to use the only parameter
The /emails endpoint was passing in the "Email" model because that's how the emails controller classifies. This was to fix that, and to allow any other such cases in the future.
This commit is contained in:
@@ -35,8 +35,10 @@ class ApplicationController < ActionController::Base
|
||||
return
|
||||
end
|
||||
|
||||
model = options[0]&.delete(:model)
|
||||
if subject.respond_to?(:includes) && (request.format.json? || request.format.xml?)
|
||||
associations = ParameterBuilder.includes_parameters(params[:only], model_name)
|
||||
model ||= model_name
|
||||
associations = ParameterBuilder.includes_parameters(params[:only], model)
|
||||
subject = subject.includes(associations)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user