2
私は最初のカスタムレールバリデーションを書いています。誤ったクラスをHTMLクラスの "error"クラスにタグ付けしたい場合、どうすればよいか分かりませんそれをやる。以下の関連性の高い検証コード。Rails 3カスタムバリデーション:違反しているフィールドを強調表示
だからあなたの形であなたが入力フィールドのために、このような何かを持っていると思います
validates_each :shop do |record, attr, value|
shopvar = record.shops.map{ |s| s.email.downcase.strip }
if shopvar.count != shopvar.uniq.count
record.errors.add(attr, 'has the same email address entered more than once')
#record.errors[attr] << "You have entered this shop in the form twice"
end
end