public Method

Errors.full_messages

Returns all the full error messages in an array.

Examples

my_person = Person.new(params[:person])

my_person.errors.add('login', 'can not be empty') if my_person.login == ''
my_person.errors.add('password', 'can not be empty') if my_person.password == ''
messages = ''
my_person.errors.full_messages.each {|msg| messages += msg + "<br />"}
messages
# => "Login can not be empty<br />Password can not be empty<br />"

Source Code

# File active_resource/validations.rb, line 161
def full_messages
  full_messages = []

  @errors.each_key do |attr|
    @errors[attr].each do |msg|
      next if msg.nil?

      if attr == "base"
        full_messages << msg
      else
        full_messages << [attr.humanize, msg].join(' ')
      end
    end
  end
  full_messages
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.