As you may know, this gem initializer file has code, which you need to uncomment to show validation error inline to every form field:
# 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
I uncommented this code, but for one special model I want to display errors as usual. I tried to refactor default code
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if "#{instance.send(:tag_id)}"!="answer_user_answer" #that's label for this model
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
end
but that doesn't work.
Thanks in advance for help