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

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


In the controller you can:

render :text => @some_object.inspect

But your view won't be rendered.

You could also:

Rails.logger.debug("My object: #{@some_object.inspect}")

and run tail on log/development.log to see the output.

In the view the recommeneded way is:

<%= debug(@some_object) %>


Don't know about print, but puts never failed me. Your hello world will be in console and logs and normal flow will continue.
Did I understand you correctly?