Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails console with Pry

I've set pry to load in place of irb when I enter rails console. I cannot find the page or remember how to bring it back to the default behavior as it seems to be interfering with my Rubymine debugger. Any suggestions?

like image 999
basheps Avatar asked Dec 04 '11 17:12

basheps


People also ask

How do I debug with pry?

To invoke the debugger, place binding. pry somewhere in your code. When the Ruby interpreter hits that code, execution stops, and you can type in commands to debug the state of the program.

Where should binding pry be placed?

But how do you know what line you should place a binding. pry ? Well that depends on what you want to find out. But, a good rule of thumb would be to place it after the section of code that is taking in, or manipulating the piece of data that you're curious about.


3 Answers

I just found the issue, pry-rails gem. Forgot that its purpose is to make 'rails console' to open pry instead.

like image 152
basheps Avatar answered Oct 11 '22 04:10

basheps


You may have modified your ~/.irbrc to start pry when IRB is loaded. Check there first.

Rails hooks into the application by loading your environment. To load your rails application into a pry session try this: pry -I . -r config/environment

like image 21
lfender6445 Avatar answered Oct 11 '22 06:10

lfender6445


Do you mean this page?

http://www.dotnetguy.co.uk/post/2011/08/23/replace-the-rails-console-with-pry

The page (now dead) contained this code, which could be what is keeping Pry running instead of IRB:

MyApp::Application.configure do
  silence_warnings do
    begin
      require 'pry'
      IRB = Pry
    rescue LoadError
    end
  end
end
like image 26
Casper Avatar answered Oct 11 '22 04:10

Casper