Rails debugging tool pry for debugger and rails C

Source: Internet
Author: User

When pry is used, you will feel that the previously used debugger method is so complicated and troublesome that it brings up the troubles of rails S and takes time to enhance IRB's functions,

By default, the pry configuration is enough, so that the rails console can also rest.

Installation:

Add in gemfile

gem ‘pry‘, :group => :development

Then execute

bundle install

You can.

Usage:

Replace the IRB method with pry and run the following command directly:

Go to rails C and run the command pry or directly run the following command line.

Use pry to replace the rails console method and run:

pry -r ./config/environment.rb

Debug rails:
Add "binding. pry" and "Rails server" directly at the place where you want to debug the code. When this line of code is run, a pry terminal is automatically called up and can be interacted here. Use "Exit-all" to exit debugging ". For example:

#/app/controllers/articles_controller.rbdef index  @articles = Article.all  binding.pryend
Common commands:
  • CD: this is not about switching directories, but about switching classes. For example, "CD article" will enter the article class. "Article. All" can be abbreviated as "all"
  • Nesting: cut by CD. If you are confused, you can use it to view the current class. I think it would be better to change the name to "PWD.
  • Ls: view some information, LS-h to view help, LS-m to view instance methods, LS-m to view class methods, and LS-P to view private methods.
  • Show-Doc array # in_groups_of: view the document.
  • Show-method-L Array # in_groups_of: view the source code of the method, and-l displays the row number.
  • Edit-method array # in_groups_of: Call up nano to edit the Code. If you can call up vim, you can. (Later I found it very simple. See later .)
  • Help: Show Help
Debug rails:

By default, pry does not have the next step that is frequently used in debugging. You need to install the commands such as the previous step.

gem "pry-nav"

Then you can use step, next, and continue to skip.

Edit and edit-method can automatically call VIM:

By default, nano editing source code is called out because $ editor is not included in the system environment variable. You can change the source code to VIM in two ways.
1. Add the environment variable $ editor = "Vim"
2. New ~ /. Pryrc configuration file, add

Pry.config.editor = "vim"

For more information, see:

Http://railscasts.com/episodes/280-pry-with-rails? View = asciicast

Https://github.com/pry/pry

Http://tyok.org/prying_ruby/

Http://blog.tyraeltong.com/blog/2011/10/14/introducing-pry/

The default scheduling tool for rails is the ruby-debug19, and the "-Debug" parameter must be added at startup. Maybe you think it is okay to use it. But if you have used pry, you will find that it can be so convenient, ruby-debug19 is so simple.
A bunch of plug-ins have been used to enhance IRB functions. Now with pry, the default configuration is enough, and the rails console can also be used.

 

Install

Add in gemfile

gem ‘pry‘, :group => :development

Then execute

bundle install

You can.

It can be used in this way

Replace the IRB method with pry and run the following command directly:

pry

Use pry to replace the rails console method and run:

pry -r ./config/environment.rb

Debug rails:
Add "binding. pry" and "Rails server" directly at the place where you want to debug the code. When this line of code is run, a pry terminal is automatically called up and can be interacted here. Use "Exit-all" to exit debugging ". For example:

#/app/controllers/articles_controller.rbdef index  @articles = Article.all  binding.pryend
Common commands
  • CD: this is not about switching directories, but about switching classes. For example, "CD article" will enter the article class. "Article. All" can be abbreviated as "all"
  • Nesting: cut by CD. If you are confused, you can use it to view the current class. I think it would be better to change the name to "PWD.
  • Ls: view some information, LS-h to view help, LS-m to view instance methods, LS-m to view class methods, and LS-P to view private methods.
  • Show-Doc array # in_groups_of: view the document.
  • Show-method-L Array # in_groups_of: view the source code of the method, and-l displays the row number.
  • Edit-method array # in_groups_of: Call up nano to edit the Code. If you can call up vim, you can. (Later I found it very simple. See later .)
  • Help: Show Help
Debug rails

By default, pry does not have the next step that is frequently used in debugging. You need to install the commands such as the previous step.

gem "pry-nav"

Then you can use step, next, and continue to skip.

Edit and edit-method can automatically call Vim

By default, nano editing source code is called out because $ editor is not included in the system environment variable. You can change the source code to VIM in two ways.
1. Add the environment variable $ editor = "Vim"
2. New ~ /. Pryrc configuration file, add

Pry.config.editor = "vim"

For more information, see:

Http://railscasts.com/episodes/280-pry-with-rails? View = asciicast

Https://github.com/pry/pry

Http://tyok.org/prying_ruby/

Http://blog.tyraeltong.com/blog/2011/10/14/introducing-pry/

The default scheduling tool for rails is the ruby-debug19, and the "-Debug" parameter must be added at startup. Maybe you think it is okay to use it. But if you have used pry, you will find that it can be so convenient, ruby-debug19 is so simple.
A bunch of plug-ins have been used to enhance IRB functions. Now with pry, the default configuration is enough, and the rails console can also be used.

 

Install

Add in gemfile

gem ‘pry‘, :group => :development

Then execute

bundle install

You can.

It can be used in this way

Replace the IRB method with pry and run the following command directly:

pry

Use pry to replace the rails console method and run:

pry -r ./config/environment.rb

Debug rails:
Add "binding. pry" and "Rails server" directly at the place where you want to debug the code. When this line of code is run, a pry terminal is automatically called up and can be interacted here. Use "Exit-all" to exit debugging ". For example:

#/app/controllers/articles_controller.rbdef index  @articles = Article.all  binding.pryend
Common commands
  • CD: this is not about switching directories, but about switching classes. For example, "CD article" will enter the article class. "Article. All" can be abbreviated as "all"
  • Nesting: cut by CD. If you are confused, you can use it to view the current class. I think it would be better to change the name to "PWD.
  • Ls: view some information, LS-h to view help, LS-m to view instance methods, LS-m to view class methods, and LS-P to view private methods.
  • Show-Doc array # in_groups_of: view the document.
  • Show-method-L Array # in_groups_of: view the source code of the method, and-l displays the row number.
  • Edit-method array # in_groups_of: Call up nano to edit the Code. If you can call up vim, you can. (Later I found it very simple. See later .)
  • Help: Show Help
Debug rails

By default, pry does not have the next step that is frequently used in debugging. You need to install the commands such as the previous step.

gem "pry-nav"

Then you can use step, next, and continue to skip.

Edit and edit-method can automatically call Vim

By default, nano editing source code is called out because $ editor is not included in the system environment variable. You can change the source code to VIM in two ways.
1. Add the environment variable $ editor = "Vim" (do not know how to change the environment variable, please refer to the http://my.oschina.net/qinlinwang/blog/30471)
2. New ~ /. Pryrc configuration file, add

Pry.config.editor = "vim"

Thanks

Http://railscasts.com/episodes/280-pry-with-rails? View = asciicast

Https://github.com/pry/pry

Http://tyok.org/prying_ruby/

Http://blog.tyraeltong.com/blog/2011/10/14/introducing-pry/

Http://rubyer.me/blog/1585/author's sharing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.