method

on_base

Importance_2
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.

on_base() public

A method to return errors assigned to base object through add_to_base, which returns nil, if no errors are associated with the specified attribute, the error message if one error is associated with the specified attribute, or an array of error messages if more than one error is associated with the specified attribute.

Examples

  my_account = Account.find(1)
  my_account.errors.on_base
  # => nil

  my_account.errors.add_to_base("This account is frozen")
  my_account.errors.on_base
  # => "This account is frozen"

  my_account.errors.add_to_base("This account has been closed")
  my_account.errors.on_base
  # => ["This account is frozen", "This account has been closed"]
Show source
Register or log in to add new notes.