Is there a way out in ruby?

I use php, and there is a convenient way out; this will stop the page from executing and allow me to view the page so far, and then let me view the debug information I need. Everything in a ruby ​​on rails

+4
source share
3 answers

You can make an exception in your code, which stops the current method and prints an exception. Great for debugging.

For example raise @variable.inspect . Also, calling the verification method will show you a lot of information about your variable. You can also use this in your view controller model helpers if you use rails.

In your opinion:

 <%= raise @variable.inspect%> 
+2
source

The best way to debug in rails is to run your server with ruby script/server --debugger debugging enabled ruby script/server --debugger (this requires a ruby ​​debugging stone) gem install ruby-debug

You can then place <% debugger %> in your views, controllers, or anywhere (obviously, omit erb tags if they are outside the view). the terminal on which the server is running will show you the breakpoint help debugger help in a prompt where you will be told more.

+5
source

Direct mapping to the PHP exit function will be Kernel :: exit () (or just exit ())

In particular, in the Rails view: <%= debug @whatever %> . Additional Information

+2
source

All Articles