Michael
Michael

Reputation: 45

NoMethodError: undefined method <<

I have an another error NoMethodError:

undefined method <<' for nil:NilClass from app/operations/bank_accounts/validate_new_transaction.rb:31:‌​in validate_existence_of_account!'

def validate_existence_of_account! 
  if @bank_account.blank?
    @errors << "Account not found" 
  end 
end 

Upvotes: 0

Views: 133

Answers (1)

Gerry
Gerry

Reputation: 10497

Your variable @errors is nil, you need to set it to Array (I assume that is what you want) before calling << on it like so:

@errors = []
@errors << "foobar"

UPDATE

You have a typo in your initialize method, use @errors instead of @erros.

Upvotes: 3

Related Questions