1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Improve AMo changelog example to not rely on AR [ci skip]

This commit is contained in:
Carlos Antonio da Silva 2012-12-19 23:03:32 -02:00
parent dd4822ce16
commit 05b80a1cce

View file

@ -2,17 +2,21 @@
* Add `ActiveModel::Validations::AbsenceValidator`, a validator to check the
absence of attributes.
class Person < ActiveRecord::Base
class Person
include ActiveModel::Validations
attr_accessor :first_name
validates_absence_of :first_name
end
person = Person.new
person.first_name = "John"
person.valid?
=> false
# first_name must be blank
# => false
person.errors.messages
# => {:first_name=>["must be blank"]}
* Roberto Vasquez Angel*
*Roberto Vasquez Angel*
* Added `ActiveModel::Errors#add_on_present` method. Adds error messages to
present attributes.