method

on_base

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"]