Is there equivalent for PHP's print_r in Ruby / Rails?

前端 未结 8 773
鱼传尺愫
鱼传尺愫 2020-12-08 03:17

In PHP you can do:

print_r($var) or vardump($var)

which prints \"human-readible\" information about variable.

Is there equ

8条回答
  •  醉酒成梦
    2020-12-08 03:39

    Guess I'm a little late to this, but what about logger.info [debug|warning]? Use this from Controllers and Models. It will show up in your log files (development.log when in dev mode); and the above mentioned <%= debug("str: " + str) %> for views.

    These aren't exact answers to your questions but you can also use script/console to load your rails app in to an interactive session.

    Lastly, you can place debugger in a line of your rails application and the browser will "hang" when your app executes this line and you'll be able to be in a debug session from the exact line your placed your debugger in the source code.

提交回复
热议问题