Friday, March 21, 2008

How to debug code in Rails 2.0.2?

The newbies of rails 2.0.2 developers may get headache because some changing are not known. Even here there is a change in the way to debug code in Rails 2.0.2.

In Rails 1.2.3, you place breakpoint command in the code then run another command ruby script\breakpointer in command dos console. At last you can debug your code by viewing some variables, changing the value, and testing what wrong with that. But, there is one limitation that you can use only instance variables, local variables could not be retrieved.

In Rails 2.0.2, these don't exist anymore. In order to debug your code, you need to install another gem by running gem install ruby-debug. Then, place debugger instead of breakpoint because this command was renamed. The script breakpointer that used to be in the folder script of your rails application now don't exist anymore. Next, you need to end your web server and then start with additional option ruby script\server --debugger. If you want to end current debugging, type cont. If you type exit, your web server will end immediately. There is one thing fixed, you can local variables in the debug mode.

No comments:

Subscribe in a Reader