Monday, 9 September 2013

How to get the value of a Controller variable in rails console

How to get the value of a Controller variable in rails console

I set a variable inside a Controller and I'm trying to just do something
as simple as read that variable in the rails console.
I thought about just doing @test in the console which is the name of the
variable. but it shows as >null. When I do puts under where I set the
variable it traces out the correct value in my terminal window.
Any ideas what I need to do to get to this variable via the console.
I tried putting the name of the controller first and then .variable but
that threw an error
I can see what's inside my models by just using the model name and some
attributes like .first and .last

No comments:

Post a Comment