validates_presence_of(*attr_names)
Instance Public methods
Validates that the specified attributes are not blank (as defined by Object#blank?), and, if the
attribute is an association, that the associated object is not marked for
destruction. Happens by default on save.
class Person < ActiveRecord::Base
has_one :face
validates_presence_of :face
end
The face attribute must be in the object and it cannot be blank or marked
for destruction.
If you want to validate the presence