Example for validates_presence_of method (closes #3966) [Robby Russell]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3677 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 6bd8e351
......@@ -364,8 +364,14 @@ def validates_acceptance_of(*attr_names)
end
end
# Validates that the specified attributes are not blank (as defined by Object#blank?). Happens by default on save.
# Validates that the specified attributes are not blank (as defined by Object#blank?). Happens by default on save. Example:
#
# class Person < ActiveRecord::Base
# validates_presence_of :first_name
# end
#
# The first_name attribute must be in the object and it cannot be blank.
#
# Configuration options:
# * <tt>message</tt> - A custom error message (default is: "can't be blank")
# * <tt>on</tt> - Specifies when this validation is active (default is :save, other options :create, :update)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册