diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-25 09:49:10 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-25 16:36:28 -0200 |
commit | 79a0488ceaa8bcf7135909872274ed09a88b4bae (patch) | |
tree | bd8bc3f15fc925728b1360e3785d4d965d30c0d1 /railties | |
parent | eb171fa328242ce355c9f6f8240cefb146115931 (diff) | |
download | rails-79a0488ceaa8bcf7135909872274ed09a88b4bae.tar.gz rails-79a0488ceaa8bcf7135909872274ed09a88b4bae.tar.bz2 rails-79a0488ceaa8bcf7135909872274ed09a88b4bae.zip |
Improve field error proc example in validations guide
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/active_record_validations_callbacks.textile | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 844876a973..4b74fae94e 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -901,13 +901,8 @@ Below is a simple example where we change the Rails behavior to always display t <ruby> ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| - if instance.error_message.kind_of?(Array) - %(#{html_tag}<span class="validation-error"> - #{instance.error_message.join(',')}</span>).html_safe - else - %(#{html_tag}<span class="validation-error"> - #{instance.error_message}</span>).html_safe - end + errors = Array(instance.error_message).join(',') + %(#{html_tag}<span class="validation-error"> #{errors}</span>).html_safe end </ruby> |