rails/rails — pull request #14313 by m-Peter (2014-03-07 14:39:57+00:00)
Title: Fix errors for four of the code samples

The four code samples that fail to run are:

- Add attribute magic to objects. Fixed by introducing a Person
instance variable.

- Tracking value changes. Fixed by replacing `attr_accessor` with
`define_attribute_methods`, providing getter and setter methods
for `name` and providing the missing `Person#save` method. A
call to `Person#save` has to precede the `person.name = 'robert'`
assignment, if we want `previous_changes` to include 'bob'.

- Adding `errors` interface to objects. Fixed by introducing a
Person instance variable, assigning `nil` to its name and calling
`Person#validate!`.

- Custom validators. Fixed by defining `HasNameValidator` before
it is used by `ValidatorPerson`.

All the code samples can now be run smoothly.