On Ruby on Rails, how do we print debug info inside of a controller?

Viewed 61532

In PHP, CGI, or in RoR's View, we can easily print out debug information. How about in the Controller, how can we just say, print "hello world" (to the webpage output) and return to continue with the view, or stop the controller right there?

6 Answers

In the controller:

 render json: @some_object
 return

It will show the object as JSON directly in the browser and stop execution. You can use some browser extensions like JSONView for Chrome to prettify the JSON in the browser.

enter image description here

Related