Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

we do not need message to be an array

  • Loading branch information...
commit 51d84c1d33ee244edfd02f4a703b852ded087370 1 parent 56fb3b1
@tenderlove tenderlove authored
Showing with 8 additions and 9 deletions.
  1. +8 −9 activemodel/lib/active_model/errors.rb
View
17 activemodel/lib/active_model/errors.rb
@@ -245,21 +245,20 @@ def add_on_blank(attributes, options = {})
# company.errors.full_messages # =>
# ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Address can't be blank"]
def full_messages
- map { |attribute, messages|
- messages = Array.wrap(messages)
-
+ map { |attribute, message|
if attribute == :base
- messages
+ message
else
attr_name = attribute.to_s.gsub('.', '_').humanize
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
- options = { :default => "%{attribute} %{message}", :attribute => attr_name }
- messages.map { |m|
- I18n.t(:"errors.format", options.merge(:message => m))
- }
+ I18n.t(:"errors.format", {
+ :default => "%{attribute} %{message}",
+ :attribute => attr_name,
+ :message => message
+ })
end
- }.flatten
+ }
end
# Translates an error message in its default scope
Please sign in to comment.
Something went wrong with that request. Please try again.