私のrefineryCMSアプリでclient_side_validationsgem(https://github.com/bcardarella/client_side_validations)を使用して、クライアント側の検証エラーをインラインで表示させようとしています。
無効なフィールドからタブアウトすると、期待どおりにspan.fieldWithErrorsタグでラップされるため、JavaScriptの検証が機能していることがわかります。ただし、ActionView :: Base.field_error_procをオーバーライドした後でも、エラーメッセージを表示させることはできません。
イニシャライザーがその後製油所(?)によってオーバーライドされているように感じます。
config / initializers / client_side_validations.rb:
# Uncomment the following block if you want each input field to have the validation messages attached.
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
unless html_tag =~ /^<label/
%{<div class="field_with_errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label></div>}.html_safe
else
%{<div class="field_with_errors">#{html_tag}</div>}.html_safe
end
end
また、config / application.rbからfield_error_procを、次の行に沿って何かを使用して設定してみました。
config.action_view.field_error_proc = Proc.new { |html_tag, instance| # etc... }
これらはどちらも、無効なフィールドのレンダリングに影響を与えないようです。何か案は??