1

I have searched for a similar problem for the past couple hours and have not found a solution. My database contains a User, Game, and Save class with migration files to correspond. When I run my game, it says

rake aborted!
ActiveRecord::StatementInvalid: Could not find table 'users'

Yesterday, I was able to run my program without any issues and it would seem something else may be the problem. When I run rake db:migrate or any other rake commands, nothing updates in the schema or db folder. I'm out of options for what the solution can be. Please help.

I am running my code on Visual Studio Code through the built-in terminal. I run my code by typing ruby bin/run.rb tty::prompt is used to navigate through the menus. When trying to create a new User or login to a user, it states the table for 'users' cannot be found.

When I run rake db:migrate --trace

It traces

rake db:migrate --trace

███████╗ ██████╗ ██████╗  ██████╗███████╗██████╗ ███████╗██████╗ 
██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝██╔══██╗██╔════╝██╔══██╗
███████╗██║   ██║██████╔╝██║     █████╗  ██████╔╝█████╗  ██████╔╝
╚════██║██║   ██║██╔══██╗██║     ██╔══╝  ██╔══██╗██╔══╝  ██╔══██╗
███████║╚██████╔╝██║  ██║╚██████╗███████╗██║  ██║███████╗██║  ██║
╚══════╝ ╚═════╝ ╚═╝  ╚═╝ ╚═════╝╚══════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
Are you a new user? no
 Login
what is your chosen name? xemnikk
rake aborted!
ActiveRecord::StatementInvalid: Could not find table 'users'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:358:in `table_structure'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `columns'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/schema_cache.rb:76:in `columns'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/schema_cache.rb:82:in `columns_hash'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/model_schema.rb:488:in `load_schema!'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/attributes.rb:247:in `load_schema!'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/attribute_decorators.rb:50:in `load_schema!'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/model_schema.rb:478:in `block in load_schema'
/Users/tobyboudreaux/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/model_schema.rb:475:in `load_schema'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/model_schema.rb:352:in `columns_hash'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/activerecord-6.0.3.2/lib/active_record/core.rb:184:in `find_by'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/lib/Main.rb:15:in `find_user'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/lib/Main.rb:93:in `login'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/lib/Main.rb:106:in `greet_user'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/lib/Main.rb:111:in `<class:Main>'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/lib/Main.rb:1:in `<top (required)>'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/require_all-3.0.0/lib/require_all.rb:208:in `require'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/require_all-3.0.0/lib/require_all.rb:208:in `__require'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/require_all-3.0.0/lib/require_all.rb:98:in `block in require_all'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/require_all-3.0.0/lib/require_all.rb:96:in `each'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/require_all-3.0.0/lib/require_all.rb:96:in `require_all'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/config/environment.rb:5:in `<top (required)>'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/Rakefile:1:in `require_relative'
/Users/tobyboudreaux/Flatiron/Code/Mod 1/ruby-project-guidelines-atx01-seng-ft-060120/Rakefile:1:in `<top (required)>'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/bin/rake:23:in `load'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/bin/rake:23:in `<main>'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `eval'
/Users/tobyboudreaux/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `<main>'
anothermh
  • 9,815
  • 3
  • 33
  • 52
  • Could please add the content of the migration file concerning the user model ? As well as the output of rake db:migrate ? – Liberatys Jun 19 '20 at 19:47
  • Please add more specific details, how do you run your program, classes code, stack trace etc. Here is the guide on how to ask https://stackoverflow.com/help/how-to-ask – Yakov Jun 19 '20 at 19:51
  • (https://github.com/Xemnikk/ruby-project-guidelines-atx01-seng-ft-060120) A link to the code on GitHub – Toby N Boudreaux Jun 19 '20 at 19:56
  • 1
    What are you doing to setup the database? You'll probably need something like `rake db:create db:migrate` or [other commands](https://stackoverflow.com/a/10302357/3784008) to get your database created and your schema loaded and your migrations run. – anothermh Jun 19 '20 at 21:06
  • Have you tried to run `rake db:schema:load` ? Its a command used to load the generated schema into the database – Liberatys Jun 19 '20 at 22:31
  • I used rake db:create_migrations for the migrate folder's files. I did db:migrate for the db creation and I have tried db:schema:load – Toby N Boudreaux Jun 19 '20 at 22:53
  • It is working now – Toby N Boudreaux Jun 19 '20 at 23:03
  • good to hear ^^ keep in mind to post things like output of commands and code in your next question so you get help a lot faster. – Liberatys Jun 19 '20 at 23:26

0 Answers0