Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access local method variable in pry

I have the following method:

  def update
    loan = Loan.find(params[:id])
    pry
    respond_with loan.update(loan_params) 
  end

So I would expect that when I get to pry in the console I should be able to type loan and get the object but instead I get "undefined local variable or method 'loan'", am I doing something wrong?

like image 501
ryudice Avatar asked Dec 25 '22 22:12

ryudice


1 Answers

You'll need to use binding.pry which will load pry in the scope of your current object (I think pry just loads a pry session without the scope.)

like image 72
Gavin Miller Avatar answered Jan 06 '23 14:01

Gavin Miller