Skip to content

Commit

Permalink
minor refactoring of #full_messages_for (now uses #inject)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpheath committed Feb 20, 2009
1 parent 4e0902f commit 7f6347b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/form_assistant.rb
Expand Up @@ -78,15 +78,12 @@ def error_message_for(field)

# Returns full error messages for given field (uses I18n)
def full_messages_for(field)
full_messages = []
attr_name = object.class.human_attribute_name(field.to_s)
attr_name = object.class.human_attribute_name(field.to_s)

object.errors[field].each do |message|
object.errors[field].inject([]) do |full_messages, message|
next unless message
full_messages << attr_name + I18n.t('activerecord.errors.format.separator', :default => ' ') + message
end

full_messages
end

# returns true if a field is invalid
Expand Down

0 comments on commit 7f6347b

Please sign in to comment.