ruby 代码
- validates_inclusion_of :class_level,
- :in => %w( Freshmen Sophomore Junior Senior),
- :message=>"must be: Freshmen, Sophomore, Junior, or Senior"
ruby 代码
- validates_acceptance_of
- validates_associated
- validates_confirmation_of
- validates_each
- validates_exclusion_of
- validates_format_of
- validates_inclusion_of
- validates_length_of
- validates_numericality_of
- validates_presence_of
- validates_size_of
- validates_uniqueness_of