0

I've just recently stopped being able to access my Models in rails console - it's like they don't exist. I can only see the Helper files, like UserHelper.rb etc. The model files have not been changed or renamed.

I've checked the solutions in other similar threads - stopping or removing spring doesn't resolve the issue - like here NameError: uninitialized constant (rails)

The only thing I've managed to do that had any effect was to change config.eager_load = false to true in config/environments/development.rb - but this setting had always been false before.

Similarly, running Rails.application.eager_load! will load all models and make them useable, but this resets after I exit/reload rails console.

I'm running Rails v 4.2.8 in the amazon cloud9 IDE

s89_
  • 1,533
  • 3
  • 25
  • 40
  • what error do you get when evaluating such a model? What does your application.rb look like? What's a filename of a model that you're trying to hit, and what's the class name? You probably aren't naming your models per Rails conventions — which is how Rails resolves the path of the model. If you have `article.rb`, it needs to be `class Article`. If you have `UserProfile`, it needs to be `user_profile.rb` – Josh Brody Jan 16 '19 at 00:59
  • So it turns out the model was accessible - I just missed out an 's' from the name... The actual problem was that the `rails c` autocomplete / suggestions when you use `tab` were not showing my Models so I assumed they weren't loaded. – s89_ Jan 16 '19 at 17:45

0 Answers0