Rails 2.3.5カスタム検証メッセージに保存されているアクティブレコードオブジェクトのフィールド値を使用していますか?
これが可能かどうかを調べるのに問題があります(Googleは今夜私の友人ではありません)。私はこの検証(@ product.save用)を持っています:
validates_uniqueness_of :product_name, :scope => [:category, :catalog_id], :message => "..."
カテゴリを明確にするエラーメッセージを希望します。同様に、言う:この場合のカテゴリは「靴」です。私がしたい何
がエラーを持っていることですが言う:
"There is already a shoes product in this catalog with the same name."
は、例えば、私が試した:
:message => "There is already a #{:category} product in this catalog with the same name."
(結果:「カテゴリの製品が、この中に既に存在し同じ名前のカタログ。」)
と
:message => "There is already a #{@product.catalog} product in this catalog with the same name."
(結果:ゼロ・エラー)
:message =>「既に%{value}製品があります...」は動作するはずです。 – mnelson