Since we learned about the require method and permit method, we will output it.
Read this article to understand the meaning and usage of the require and permit methods.
One of the strong parameter methods, which specifies the object name of the data fetched from params.
Usage example
def user_params
params.require(:user)
end
This specifies the data for an object called a user.
One of the strong parameters, which specifies the key of the data fetched from params.
Usage example
def
tweet_params
params_permit(:name, :text, :image)
end
So the difference between the two is whether you specify a key or an object.
Therefore, the permit method and the require method may be used at the same time.
Example
def user_params
params.require(:user).permit(:name, :email, :password)
end
The user object is specified, and the name, email, and password keys defined in the user object are specified.
Recommended Posts