Giter Site home page Giter Site logo

Comments (17)

jaredatron avatar jaredatron commented on September 6, 2024 25
# .pryrc checked into my project root
require 'rails/console/app'
include Rails::ConsoleMethods

from pry-rails.

umuro avatar umuro commented on September 6, 2024 9

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.

counterbeing avatar counterbeing commented on September 6, 2024 1

that did the trick @deadlyicon 👍

from pry-rails.

eagsalazar avatar eagsalazar commented on September 6, 2024

same problem. please document a workaround or add these helpers. Thanks.

from pry-rails.

scottwater avatar scottwater commented on September 6, 2024

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.

Tomtomgo avatar Tomtomgo commented on September 6, 2024

Is there a way to add this to the 'rails c' startup sequence? Now I'ḿ copy-pasting this everytime...

from pry-rails.

scottwater avatar scottwater commented on September 6, 2024

@Tomtomgo - Grab the latest version of the gem. The fix has been merged in.

from pry-rails.

Tomtomgo avatar Tomtomgo commented on September 6, 2024

Nice one.

from pry-rails.

joshco avatar joshco commented on September 6, 2024

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:inpry'
[5] pry(main)> reload!
NoMethodError: undefined method reload!' for main:Object from (pry):5:inpry'
[6] pry(main)> self.send(:include, Rails::ConsoleMethods)
NameError: uninitialized constant Rails::ConsoleMethods
from (pry):6:in `pry'
[7] pry(main)>

from pry-rails.

volkanunsal avatar volkanunsal commented on September 6, 2024

Same problem here....

from pry-rails.

lishuaiii avatar lishuaiii commented on September 6, 2024

Same problem

from pry-rails.

jessicard avatar jessicard commented on September 6, 2024

Same problem on Rails 3.2, Ruby 2.1.1 :(

from pry-rails.

rf- avatar rf- commented on September 6, 2024

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 cded or binding.pryed 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.

lime avatar lime commented on September 6, 2024

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.

baweaver avatar baweaver commented on September 6, 2024

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.

g8d3 avatar g8d3 commented on September 6, 2024

thanks @umuro .

from pry-rails.

jaredatron avatar jaredatron commented on September 6, 2024

cheer

from pry-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.