Debug Rails Controllers from Console

When working with Ruby objects it’s often helpful to call individual methods in the console. This is helpful in development and debugging.

Rails allows you to do the same in controllers. Infact you can create the same type of session as the one used in integration tests, allowing you to execute arbitrary requests.

You can call get, post, put, and others; or you can call process and pass the method name as the first argument. Request headers, parameters, Rack env, XHR status, and requested format can be customized when calling.

The session stores references to the request, response, and controller objects, which you can easily inspect in the console. Perfect tool for troubleshooting controller-level problems.


credits to @gregnavis