What is the best way for me to determine a controller variable’s value during execution?
For example, is there a way I can insert a break in the code, and cause the value of the variable to be output to the screen (or the log)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. The easiest way is to raise the value as a string. Like so:
raise @foo.to_sOr, you can install the debugger (
gem install ruby-debug), and then start the development server with the--debuggerflag. Then, in your code, call thedebuggerinstruction.Inside the debugger prompt, you have many commands, including
pto print the value of a variable.Update: here’s a bit more about ruby-debug.