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

Fixes in AMo README

This commit is contained in:
Carlos Antonio da Silva 2012-02-07 20:29:02 -02:00
parent e3e7e0513b
commit 9296996029

View file

@ -87,10 +87,9 @@ modules:
errors.add(:name, "can not be nil") if name.nil? errors.add(:name, "can not be nil") if name.nil?
end end
def ErrorsPerson.human_attribute_name(attr, options = {}) def self.human_attribute_name(attr, options = {})
"Name" "Name"
end end
end end
person.errors.full_messages person.errors.full_messages
@ -163,7 +162,7 @@ modules:
* Custom validators * Custom validators
class Person class ValidatorPerson
include ActiveModel::Validations include ActiveModel::Validations
validates_with HasNameValidator validates_with HasNameValidator
attr_accessor :name attr_accessor :name
@ -171,7 +170,7 @@ modules:
class HasNameValidator < ActiveModel::Validator class HasNameValidator < ActiveModel::Validator
def validate(record) def validate(record)
record.errors[:name] = "must exist" if record.name.blank? record.errors[:name] = "must exist" if record.name.blank?
end end
end end
@ -182,7 +181,7 @@ modules:
p.valid? # => true p.valid? # => true
{Learn more}[link:classes/ActiveModel/Validator.html] {Learn more}[link:classes/ActiveModel/Validator.html]
== Download and installation == Download and installation