Debugging rails application is  very easy.

Install ruby-debugger gem
  gem install ruby-debugger

Then you simply have to start server with:
  ruby script/server --debugger
debugger only works with Mongrel and Webrick

In your code you can put debugger every where you need it

When the line after debugger command has to be executed the server stops and allows you to debug your code.
Typing help command you will see the list of commands available:
  list  shows the code under execution
  next  goes to the next line to be executed
  continue  continue to execution of the code
  p variable_name  print the current value of the variable_name
  irb  lunch the console through wich you can modify variables value