Closed RYUTAONO0929 closed 5 years ago
permissionについてはWindowsのWSL固有の事象な気がしますね。これかな? https://qiita.com/minwinmin/items/bf1664fc861932db884c
実現したいことのところは参考書のページではなく具体的にやりたいことを言語化して記載して頂きたいです:bow: 事象を言語化して正確に表現することも重要なため。
PG::UndefinedTable: ERROR: relation "users" does not exist
の部分はどう解釈した感じでしょうか?
@RYUTAONO0929 ご確認願います:bow:
質問方法の件、申し訳ありませんでした。次回からそのように記述させていただきます。 userモデルを作ったのにusersと表示されているので、疑問に感じていました。 どこかでusersと間違えて入力してしまったのでしょうか。
質問方法の件、申し訳ありませんでした。次回からそのように記述させていただきます。
ありがとうございます:bow:
userモデルを作ったのにusersと表示されているので、疑問に感じていました
これは User
とRails側のmodelで定義するとデータベース側(postgresql)で users
というテーブルが作られるような仕組みになっているためですね。これはRailsがmodel名からテーブル名を推測して処理してくれるようになっています。
つまりは users
のテーブルが存在しない状態なのかなと思っています。 does not exist
なので。
まずは
$ bundle exec rails dbconsole
とかしてdbconsoleを立ち上げてテーブルが定義されているかどうか確認すると良いと思います。 http://tamata78.hatenablog.com/entry/2015/09/24/224839
データベースを確認したところusersというテーブルが存在しなかったため、もう一度rails gでモデルを作り直し、rails db:migrateしたのですが、このようになります。
ryutaono@DESKTOP-G6D20US:~/taskleaf$ bundle exec rails dbconsole
psql (10.6 (Ubuntu 10.6-0ubuntu0.18.04.1))
Type "help" for help.
taskleaf_development=# db_name=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
--------------------------+----------+----------+---------+---------+-----------------------
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
scaffold_app_development | ryutaono | UTF8 | C.UTF-8 | C.UTF-8 |
scaffold_app_test | ryutaono | UTF8 | C.UTF-8 | C.UTF-8 |
taskleaf_development | ryutaono | UTF8 | C.UTF-8 | C.UTF-8 |
taskleaf_test | ryutaono | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(7 rows)
taskleaf_development-# quit
taskleaf_development-# quit
taskleaf_development-# ^C
taskleaf_development=# help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
taskleaf_development=# \q
ryutaono@DESKTOP-G6D20US:~/taskleaf$ rails g model user name:string email:string password_digest:string
/home/ryutaono/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Running via Spring preloader in process 1186
invoke active_record
conflict db/migrate/20190306170638_create_users.rb
Another migration is already named create_users: /home/ryutaono/taskleaf/db/migrate/20190306142802_create_users.rb. Use --force to replace this migration or --skip to ignore conflicted file.
ryutaono@DESKTOP-G6D20US:~/taskleaf$ bin/rails db:migrate
== 20190306142802 CreateUsers: migrating ======================================
-- create_table(:users)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "email" does not exist
: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `async_exec'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:579:in `block (2 levels) in log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:578:in `block in log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:569:in `log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:466:in `add_index'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:315:in `block in create_table'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in `each'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in `create_table'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:871:in `block in method_missing'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:840:in `block in say_with_time'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:840:in `say_with_time'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:860:in `method_missing'
/home/ryutaono/taskleaf/db/migrate/20190306142802_create_users.rb:3:in `change'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:814:in `exec_migration'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:797:in `block in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:796:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:977:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1343:in `block in ddl_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in `block in transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in `transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/transactions.rb:212:in `transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1343:in `ddl_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1262:in `each'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1210:in `block in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1210:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1036:in `up'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1011:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/command.rb:48:in `invoke'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<main>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
/home/ryutaono/taskleaf/bin/rails:9:in `<top (required)>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/ryutaono/taskleaf/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "email" does not exist
: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `async_exec'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:579:in `block (2 levels) in log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:578:in `block in log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:569:in `log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:466:in `add_index'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:315:in `block in create_table'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in `each'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in `create_table'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:871:in `block in method_missing'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:840:in `block in say_with_time'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:840:in `say_with_time'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:860:in `method_missing'
/home/ryutaono/taskleaf/db/migrate/20190306142802_create_users.rb:3:in `change'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:814:in `exec_migration'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:797:in `block in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:796:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:977:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1343:in `block in ddl_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in `block in transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in `transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/transactions.rb:212:in `transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1343:in `ddl_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1262:in `each'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1210:in `block in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1210:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1036:in `up'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1011:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/command.rb:48:in `invoke'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<main>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
/home/ryutaono/taskleaf/bin/rails:9:in `<top (required)>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/ryutaono/taskleaf/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
PG::UndefinedColumn: ERROR: column "email" does not exist
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `async_exec'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:579:in `block (2 levels) in log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:578:in `block in log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:569:in `log'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:466:in `add_index'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:315:in `block in create_table'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in `each'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in `create_table'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:871:in `block in method_missing'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:840:in `block in say_with_time'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:840:in `say_with_time'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:860:in `method_missing'
/home/ryutaono/taskleaf/db/migrate/20190306142802_create_users.rb:3:in `change'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:814:in `exec_migration'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:797:in `block in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:796:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:977:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1343:in `block in ddl_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in `block in transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in `transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/transactions.rb:212:in `transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1343:in `ddl_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1262:in `each'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1210:in `block in migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1210:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1036:in `up'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:1011:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/command.rb:48:in `invoke'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<main>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
/home/ryutaono/taskleaf/bin/rails:9:in `<top (required)>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/ryutaono/taskleaf/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/ryutaono/taskleaf/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
migrateのエラーでしょうか?
データベースを確認したところusersというテーブルが存在しなかったため
まず記事にも書いてますが
taskleaf_development=# db_name=> \l
はデータベースの一覧を確認するコマンドなのでテーブルの一覧表示ではないですね
なので users
テーブルが存在しないことは確認できていないと思います:bow:
もう一度rails gでモデルを作り直し
これをやる前にmigrationファイルの存在を確認した方が良いかなと思いました。
db/migrate
というディレクトリの配下にマイグレーションファイルがあるのでそこにusers
のテーブルを生成するためのマイグレーションファイルが存在するかどうか確認した方が良いと思います:bow:
ryutaono@DESKTOP-G6D20US:~/taskleaf$ db/migrate
-bash: db/migrate: Is a directory
ryutaono@DESKTOP-G6D20US:~/taskleaf$
マイグレーションファイルは存在するようです。
まずusers テーブルが存在しないことは確認できていないと思うのでこちらの確認からお願いします:bow:
次に $ db/migrate
はディレクトリをみているだけなので
usersのテーブルを生成するためのマイグレーションファイルが存在するかどうか
については確認できていないと思います:bow:
解決しました!
db/migrateの中のxxxx_create_users.rbを確認したところemailがemailsとなっていた事が原因でした。 確認をしっかりしてから質問させていただくべきでした。 今後このようなことのないように致します。 申し訳ありませんでした。
@RYUTAONO0929
原因がわかったようで良かったです!
確認をしっかりしてから質問させていただくべきでした。 今後このようなことのないように致します。 申し訳ありませんでした。
謝らなくて大丈夫です!質問して頂くのも全然OKです!(そのためのmentaなので:bow:) ただ問題解決するための手段の習得と論理的思考を身につけていくと良いと思います:bow:
今回の場合だと例えば
(1) users does not exist => テーブルがない可能性がある (2) postgresqlでusers テーブルの存在確認 (3) テーブルが存在しない => テーブル生成の元になっているmigrationファイルの存在確認 (4) migrationファイルの定義に問題がないか確認
とか順をおって確認していけば問題の原因にたどり着けるのでそういった思考を持つように心がけると再現性の高い技術力が身につくのかなと思いました:smile: 頑張ってください:smile:
ありがとうございます。 次回からそのように考えてみます。
概要
rails g model~でモデルを作成した後4-5-2,p152にあるようにサンプルの内容を加えようとすると:UndefinedTable: ERROR: relation "users" does not existと怒られてしまいます。
実現したいこと
現場で使えるRuby on Rails 4-5-2,p152
困っていること
困っていることがバグの場合は事象やログ、エラーメッセージをできるだけそのまま(抜粋などしない)下記に記載してください。
解決するために行ったこと
なぜかpcを起動するたびにパーミッションが変更されるのでchmod -R 755 ~で一括で変更しました。 確認したところ
でした。
問題となっている箇所の予想
問題となっているアプリケーションのGitHub URL