Rails 7.1 Adds exclude? And extract_value methods To ActionController::Parameters
Rails ActionController::Parameters
is a convenient way to pass data from a request to a controller action.
It allows us to choose which attributes should be permitted for mass updating and thus prevents accidentally exposing parameters that shouldn’t be exposed.
Before exclude?
To check if the given key is present in the parameters, we can use the include?
method, but ActionController::Parameters
does not provide any method to check if the given key is not present in the parameters.
params = ActionController::Parameters.new(name: "John", age: 26)
params.include?("name") #=> true
After exclude?
Rails 7.1 adds exclude? method to ActionController::Parameters. It is the inverse of inclu…
The exc…