Comments (17)
# .pryrc checked into my project root
require 'rails/console/app'
include Rails::ConsoleMethods
from pry-rails.
Reload workaround is as follows:
~/.pryrc
if defined?(Rails) && Rails.env
if defined?(Rails::ConsoleMethods)
include Rails::ConsoleMethods
else
def reload!(print=true)
puts "Reloading..." if print
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
true
end
end
end
from pry-rails.
that did the trick @deadlyicon 👍
from pry-rails.
same problem. please document a workaround or add these helpers. Thanks.
from pry-rails.
A short term fix is to do this in the console:
self.send(:include, Rails::ConsoleMethods)
I have a pull request coming which does this as well....although it feels a little dirty.
from pry-rails.
Is there a way to add this to the 'rails c' startup sequence? Now I'ḿ copy-pasting this everytime...
from pry-rails.
@Tomtomgo - Grab the latest version of the gem. The fix has been merged in.
from pry-rails.
Nice one.
from pry-rails.
I'm still seeing a problem : (Win7 mingw, pry 0.9.10)
pry is the only gem installed (no pry-*)
Im running pry -r ./config/environment
[4] pry(main)> reload
NameError: undefined local variable or method reload' for main:Object from (pry):4:in
pry'
[5] pry(main)> reload!
NoMethodError: undefined method reload!' for main:Object from (pry):5:in
pry'
[6] pry(main)> self.send(:include, Rails::ConsoleMethods)
NameError: uninitialized constant Rails::ConsoleMethods
from (pry):6:in `pry'
[7] pry(main)>
from pry-rails.
Same problem here....
from pry-rails.
Same problem
from pry-rails.
Same problem on Rails 3.2, Ruby 2.1.1 :(
from pry-rails.
In addition to the possibility that this is a bug, there are a couple of non-bug reasons this could be happening to you.
First of all, the helpers are only available if you run rails console
, not if you use binding.pry
within your app. This is following the lead of Rails, which only loads those methods in the console context and not when you run rails server
or specs or whatever.
Another potential reason they might not be there is if you've cd
ed or binding.pry
ed into a context other than the top level. Before Rails 3.2, the app
, helper
, and reload!
methods got mixed into Object
, so they would be available regardless of what context you're running code in. Since Rails 3.2, they've been mixed into the top-level context (main
) instead, so they're only available in the context that the console initially starts in. We could change that, but it would be different from the stock behavior of Rails.
BTW, I feel like either of those decisions could be revisited if people want the extra convenience in exchange for monkey-patching Object
more aggressively. I don't think anyone has ever explicitly asked for those changes, but they would probably reduce confusion, so maybe we should talk about it.
If anyone in this thread is seeing this problem and the reasons above don't apply, please leave some extra details about what you're doing so that we can try to track down what's going on.
from pry-rails.
Thanks @rf-, that clarifies a lot of things! I was pretty confused when rails console
gave me the helpers while zeus console
and binding.pry
did not.
Also, I think the initiative to consider changing this behaviour is great. Maybe it should have its own issue however, so as not to hijack this discussion?
from pry-rails.
I'd consider that for another issue. If you're in a Rails app, chances are high that you probably want to have everything loaded in as well.
from pry-rails.
thanks @umuro .
from pry-rails.
from pry-rails.
Related Issues (20)
- Include documentation for use with pry-nav
- Pry.config.should_load_plugins doesn't work
- rails ri documentation not functioning after upgrade from ruby 2.4.4 to ruby 2.4.5 HOT 1
- warning: constant Pry::Prompt::MAP is deprecated HOT 1
- Make pry-rails opt-in? HOT 5
- before_session hook failed: NoMethodError: undefined method `chomp' for nil:NilClass HOT 4
- Segmentation fault with ruby 2.6.2 HOT 4
- clear-screen failing with unintialized constant
- NoMethodError on rails console HOT 1
- issue create by mistake
- Issue with pry rails prompt HOT 3
- --simple-prompt option ignored when using pry-rails
- Unicode problems in console HOT 1
- Could not run find-routes HOT 2
- `find-method` fails inside Rails application (undefined method `is_a?' for #<BasicObject>) HOT 1
- Why no Changelog?
- undefined method `source_index' for Gem:Module HOT 2
- Pry not starting after installing pry-rails HOT 12
- `DISABLE_PRY_RAILS=1 rails c` is not disabling pry at the console HOT 4
- Mixing reload! into Rails binding.pry sessions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pry-rails.