TIL - Today I Learned
Wednesday, 11/20/19
Explaining require
and permit
: params.require(:person).permit(:name, :age)
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters
, which provides several methods such as require
and permit
.
The require
method ensures that a specific parameter is present, and if it's not provided, the require
method throws an error. It returns an instance of ActionController::Parameters
for the key passed into require.