module ActiveRecord::Validations::ClassMethods
def validates_presence_of(*attr_names)
it is both present and valid, you also need to use
if the latter was assigned but not valid. If you want to ensure that
NOTE: This validation will not fail while using it with an association
more information.
See ActiveModel::Validations::HelperMethods.validates_presence_of for
state.
deletes the associated object, thus putting the parent object into an invalid
prevents the parent object from validating successfully and saving, which then
check to see that an associated object is not marked for destruction. This
This validator defers to the Active Model validation for presence, adding the
for destruction.
The face attribute must be in the object and it cannot be blank or marked
end
validates_presence_of :face
has_one :face
class Person < ActiveRecord::Base
is also considered blank if it is marked for destruction.
Object#blank?). If the attribute is an association, the associated object
Validates that the specified attributes are not blank (as defined by
def validates_presence_of(*attr_names) validates_with PresenceValidator, _merge_attributes(attr_names) end