Siva
Siva

Reputation: 8058

Rails Debug - How to print variable values on every step

Say I have a variable called @test_var

And I have hundred lines of code using this variable

On debugging I need to give n for next step and @test_var to check the value

Can I do both in single command (i.e) print the value of a variable on every step ?

Upvotes: 0

Views: 2563

Answers (3)

Igor Kasyanchuk
Igor Kasyanchuk

Reputation: 774

My own solution to print and debug variables is https://github.com/igorkasyanchuk/wrapped_print

you can simply call @test_var.wp to see in the logs a value of this variable

Upvotes: 0

deivid
deivid

Reputation: 5258

You are looking for

display @test_var

After that, @test_var will be printed every time the debugger stops.

Upvotes: 1

Debadatt
Debadatt

Reputation: 6015

If you want to print it in controller then

for each line give one heading like

p "step 1"
p @test_var

p "step 2"
p @test_var

Upvotes: 0

Related Questions