Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing reload! into Rails binding.pry sessions #99

Open
jm3 opened this issue Feb 8, 2018 · 1 comment
Open

Mixing reload! into Rails binding.pry sessions #99

jm3 opened this issue Feb 8, 2018 · 1 comment

Comments

@jm3
Copy link

jm3 commented Feb 8, 2018

Hi, just opened pry/pry#1743. I know now that recent Rails versions only mix in reload! and friends to the top-level REPL context, as opposed to mixing them into Object, which means they won't be available inside a binding.pry session in the context of a specific class.

@rf- said:

You might be able to make it work by running extend Rails::ConsoleMethods after starting the session (possibly after running require "rails/console/app" and require "rails/console/helpers"). If that doesn't help then feel free to open an issue on pry-rails and we could discuss ways of making this easier.

Running that in my Rails binding.pry session did indeed work. Now I'd like to avoid typing it every time I run pry. To that end, I tried pasting it into my ~/.irbrc file, and into a ~/.pryrc file, but it didn't seem to work.

Any tips for making pry run this automatically for future Rails sessions?

@jm3 jm3 changed the title Invoking pry from within Rails Mixing reload! into Rails binding.pry sessions Feb 8, 2018
@rf-
Copy link
Member

rf- commented Feb 8, 2018

Maybe try Object.send(:include, Rails::ConsoleMethods) instead of the extend line in your .pryrc? If you wrapped it in an if defined?(Rails) or something then it should be pretty safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants