method

each

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: ActiveResource::Errors

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

These similar methods exist in v7.1.3.2:

each() public

Yields each attribute and associated message per error added.

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.each {|attr, msg| messages += attr.humanize + " " + msg + "<br />"}
  messages
  # => "Login can not be empty<br />Password can not be empty<br />"
Show source
Register or log in to add new notes.