app/models/label.rb
def ensure_does_not_have_accounts
    if accounts.count > 0
      s = pluralize(accounts.length, "account")
      errors.add(:base,
                 "#{name} still has #{s}")
      return false
    end
    return true
  end
# If label has one or more accounts, it cannot be deleted
If label has one or more accounts, it cannot be deleted
If label has one or more accounts it cannot be deleted
def ensure_does_not_have_accounts
    if accounts.count > 0
      s = pluralize(accounts.length, "account")
      errors.add(:base,
                 "#{name} still has #{s}")
      return false
    end
    return true
  end
def ensure_does_not_have_accounts if accounts . count > 0 s = pluralize ( accounts . length , "account" ) errors . add ( :base , "#{name} still has #{s}" ) return false end return true end
If label has one or more accounts, it cannot be deleted
If label has one or more accounts it cannot be deleted