I'm trying to save a User but ActiveRecord can't find my table. Also 'rake db:schema:dump' does not produce a schema.rb file, I have done my create table migrations and the default 'development.sqlite' database has been created when I do so. Afterwards I enter:
pry(main)> User.create({username: "test", email: "[email protected]", password_digest: "foobar"})
and see :
ActiveRecord::StatementInvalid: Could not find table 'users' from /home/me/.rvm/gems/ruby-2.6.1/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:346:in `table_structure'
upon sticking a 'binding.pry' on line 346 in sqlite3_adapter.rb I try to find the value of both "table_name" and "@config" and I see that both of these appear to be set up correctly:
pry(#<ActiveRecord::ConnectionAdapters::SQLite3Adapter>)> table_name
=> "users"
[2] pry(#<ActiveRecord::ConnectionAdapters::SQLite3Adapter>)> @config
=> {:adapter=>"sqlite3", :database=>"db/development.sqlite"}
This appears to be correct to me unless I am missing something. I wrote the migration as:
class CreateUsers < ActiveRecord::Migration[6.1]
def change
create_table :users do |t|
t.string :username
t.string :email
t.string :password_digest
end
end
end
I have looked here and have been googling. Looking for a clue as to what might be the problem.
You will need to "run" the migration: