I have a rails app (rails 5). In development, everything work, when i use
rails console
And enter an instruction, for example User.a
I had this problem and realized it happened after I made a tweak to one of my job files. What fixed it was restarting the spring loader. Just run
spring stop
Then the next time you run the rails console
it should load things as normal.
I had this same issue, rewolf's answer above solved it for me temporarily.
Just to add to his answer:
After stopping the spring gem by running the command below
spring stop
You can also fix this issue permanently by upspringing (removing the spring gem from) your bin/
executables:
bin/spring binstub --remove --all
Or
spring binstub --remove --all
You can now run the command below to get into rails console in production
rails c --environment=production
Also, to avoid this from occurring in subsequent occasions endeavour to make sure that the spring gem is only present in development
and test
groups in your Gemfile.
Moreso, when you're in production make sure you always provide the --without development test
argument to the bundle install
command
bundle install --without development test
and not the usual or common
bundle install
Please note: As an indication, whenever you run the command rails c
or rails console
and you see the output below:
Running via Spring preloader in process 26651 WARNING: Spring is running in production. To fix this make sure the spring gem is only present in
development
andtest
groups in your Gemfile and make sure you always usebundle install --without development test
in production
It's an indication that the spring gem is running in your production environment, and it should be stopped or removed entirely from your bin executables.
That's all.
I hope this helps