Reputation: 3516
Lets say I have the code
params.require(:foo).permit(:a, :b, :c)
and the params came in as
params: {:foo => {a: 0, b: 1, c: 2, d: 3}}
I would get
unpermitted paramter: d
How can I access unpermitted parameters in the controller, or see if any were passed by the user?
Upvotes: 2
Views: 334
Reputation: 3870
Looking at the source of ActionController::Parameters
:
You'll need to set this (in an initializer or otherwise):
ActionController::Parameters.action_on_unpermitted_parameters = :raise
This will raise a new ActionController::UnpermittedParameters
exception which you can intercept and extract the unpermitted parameters.
Upvotes: 3