It is a function to check if the corresponding column contains data when the parameter is received.
In the following example, check if the name column is nil (no data). If it is nil, it will not be saved.
app/models/user.rb
class User < ApplicationRecord
validates :name, presence: true
end
Recommended Posts