class ActiveModel::Errors

def [](attribute)

person.errors['name'] # => ["cannot be nil"]
person.errors[:name] # => ["cannot be nil"]

for the method.
When passed a symbol or a name of a method, returns an array of errors
def [](attribute)
  messages_for(attribute)
end