Railsドキュメント

属性のHashとそのエラーメッセージを取得

適応バージョン

説明

属性のHashとそのエラーメッセージを取得

使い方

モデル.errors.to_hash(完全なメッセージか=false)

person.errors.to_hash
#=> {:name=>["cannot be nil"]}
person.errors.to_hash(true)
#=> {:name=>["name cannot be nil"]}

ソースコード