[Rails] require method and permit method

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.

What is the require method?

One of the strong parameter methods, which specifies the object name of the data fetched from params.

Usage example

def user_params

This specifies the data for an object called a user.

What is the permit method?

One of the strong parameters, which specifies the key of the data fetched from params.

Usage example

params_permit(:name, :text, :image)

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.


def user_params
 params.require(:user).permit(:name, :email, :password)

The user object is specified, and the name, email, and password keys defined in the user object are specified.

Recommended Posts

[Rails] require method and permit method
Rails "render method" and "redirect method"
rails method
Rails and FormData
Rails delegate method
variable and method
[Rails] Difference between create method and new + save method
[Rails] devise helper method
[Rails] devise introduction method
Understanding ruby's "|| =" specification and what is Rails presence method?
about the where method (rails)
[Rails] N + 1 problems and countermeasures
Rails: Difference between resources and resources
Rails Posts and User Linkage
Rails Tutorial Records and Memorandum # 0
rails path and url methods
Rails is difficult and painful!
Introducing Bootstrap and Font-Awesome (Rails)
Rails is difficult and painful! Ⅱ
Java methods and method overloads
[Rails] strftime this and that
[Rails] Search method when date and time have each column
Rails web server and application server
About Rails scraping method Mechanize
Difference between render method and redirect_to
Difference between == operator and equals method
[Rails] Save start time and end time
Enable jQuery and Bootstrap in Rails 6 (Rails 6)
[Ruby] present/blank method and postfix if.
[Rails] Difference between find and find_by
[Java beginner] == operator and equals method
[Ruby basics] split method and to_s method
[Rails] Validation settings and Japanese localization
Rails model and table naming conventions
[Rails] About helper method form_with [Basic]
Remove "assets" and "turbolinks" in "Rails6".
CRUD features and MVC in Rails
[Rails] Differences and usage of each_with_index and each.with_index
[Swift] Protocol concept and definition method
Project ruby and rails version upgrade
[Rails 6] destroy using the resources method
[Ruby on Rails] Convenient helper method
Consideration about Rails and Clean Architecture
[rails] Difference between redirect_to and render
[Rails] I studied the difference between new method, save method, build method and create method.