Pry: auto-completion only works after class has been used once

Created on 7 Apr 2014  路  6Comments  路  Source: pry/pry

Auto-completion, as well as other functions like show-source, don't work properly on my active record models/classes until I use the model once. For example:

[1] pry(main)> show-source AdminControllerAcl
Error: Couldn't locate a definition for AdminControllerAcl!
[2] pry(main)> AdminControllerAcl.last
=> nil
[3] pry(main)> show-source AdminControllerAcl

From: /space/rxg/console/app/models/admin_controller_acl.rb @ line 16:
Class name: AdminControllerAcl
Number of monkeypatches: 4. Use the -a option to display all available monkeypatches
Number of lines: 17

class AdminControllerAcl < ActiveRecord::Base
has_and_belongs_to_many :policies
has_and_belongs_to_many :wan_targets

Is this normal?

feature

Most helpful comment

Yep, Rails.application.eager_load! will load everything in your app directory.

All 6 comments

that stinks. Kind of defeats the purpose if I have to remember the method name before I can autocomplete it :) Is there any command I can run or add to my .pryrc that will tell it to preload all my classes?

Yep, Rails.application.eager_load! will load everything in your app directory.

Pry launches in about a minute on this box when I use eager_load. I think I'll leave it out of my pryrc, and just load it when I intend to need it.

Thanks

I think another option might be for us to be more aggressive about trying to constantize the thing on the left side of the dot, such that it sets off Rails constant loading magic. Not sure how hard that would be since I've never looked at our completion code.

@ghost it seems this is still an issue. Could you perhaps elaborate a bit on the solution you hinted at above, so that anyone interested can pick it up and submit a pull request?

I'm hacking on a project without rails. In my code I have a few instance variables defined which do not autocomplete, but regular variables do. Is this by design or can that be easily added to autocomplete?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbbroberg picture mbbroberg  路  4Comments

benoittgt picture benoittgt  路  4Comments

brandoncc picture brandoncc  路  6Comments

phoet picture phoet  路  9Comments

drmohundro picture drmohundro  路  4Comments