質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

2015閲覧

rails tutorial 10.2.3におけるエラー

souuta

総合スコア8

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2017/03/07 13:28

###前提・実現したいこと
rails tutorialの4版における10.2.3を進めていたところ、最後のテストでエラーが発生してしまいました。

https://railstutorial.jp/chapters/account_activation_password_reset?version=4.2#cha-account_activation_and_password_reset

###発生している問題・エラーメッセージ

# Running: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE Finished in 1.885435s, 19.0937 runs/s, 0.0000 assertions/s. 1) Error: UsersSignupTest#test_invalid_signup_infomation: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersSignupTest#test_invalid_signup_infomation: NoMethodError: undefined method `each' for nil:NilClass 2) Error: UsersSignupTest#test_valid_signup_information_with_account_activation: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersSignupTest#test_valid_signup_information_with_account_activation: NoMethodError: undefined method `each' for nil:NilClass 3) Error: StaticPagesControllerTest#test_should_get_contact: ActiveRecord::StatementInvalid: Could not find table 'users' Error: StaticPagesControllerTest#test_should_get_contact: NoMethodError: undefined method `each' for nil:NilClass 4) Error: StaticPagesControllerTest#test_should_get_help: ActiveRecord::StatementInvalid: Could not find table 'users' Error: StaticPagesControllerTest#test_should_get_help: NoMethodError: undefined method `each' for nil:NilClass 5) Error: StaticPagesControllerTest#test_should_get_home: ActiveRecord::StatementInvalid: Could not find table 'users' Error: StaticPagesControllerTest#test_should_get_home: NoMethodError: undefined method `each' for nil:NilClass 6) Error: StaticPagesControllerTest#test_should_get_about: ActiveRecord::StatementInvalid: Could not find table 'users' Error: StaticPagesControllerTest#test_should_get_about: NoMethodError: undefined method `each' for nil:NilClass 7) Error: UsersEditTest#test_unsuccessful_edit: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersEditTest#test_unsuccessful_edit: NoMethodError: undefined method `each' for nil:NilClass 8) Error: UsersEditTest#test_successful_edit_with_friendly_forwarding: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersEditTest#test_successful_edit_with_friendly_forwarding: NoMethodError: undefined method `each' for nil:NilClass 9) Error: UsersControllerTest#test_should_redirect_destroy_when_not_logged_in: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_redirect_destroy_when_not_logged_in: NoMethodError: undefined method `each' for nil:NilClass 10) Error: UsersControllerTest#test_should_redirect_index_when_not_logged_in: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_redirect_index_when_not_logged_in: NoMethodError: undefined method `each' for nil:NilClass 11) Error: UsersControllerTest#test_should_redirect_edit_when_not_logged_in: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_redirect_edit_when_not_logged_in: NoMethodError: undefined method `each' for nil:NilClass 12) Error: UsersControllerTest#test_should_redirect_update_when_not_logged_in: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_redirect_update_when_not_logged_in: NoMethodError: undefined method `each' for nil:NilClass 13) Error: UsersControllerTest#test_should_get_new: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_get_new: NoMethodError: undefined method `each' for nil:NilClass 14) Error: UsersControllerTest#test_should_redirect_update_when_logged_in_as_wrong_user: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_redirect_update_when_logged_in_as_wrong_user: NoMethodError: undefined method `each' for nil:NilClass 15) Error: UsersControllerTest#test_should_redirect_destroy_when_logged_in_as_a_non-admin: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_redirect_destroy_when_logged_in_as_a_non-admin: NoMethodError: undefined method `each' for nil:NilClass 16) Error: UsersControllerTest#test_should_redirect_edit_when_logged_in_as_wrong_user: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersControllerTest#test_should_redirect_edit_when_logged_in_as_wrong_user: NoMethodError: undefined method `each' for nil:NilClass 17) Error: UserMailerTest#test_account_activation: ActiveRecord::StatementInvalid: Could not find table 'users' 18) Error: UserMailerTest#test_password_reset: ActiveRecord::StatementInvalid: Could not find table 'users' 19) Error: SessionsHelperTest#test_current_user_returns_nil_remember_digest_is_wrong: ActiveRecord::StatementInvalid: Could not find table 'users' Error: SessionsHelperTest#test_current_user_returns_nil_remember_digest_is_wrong: NoMethodError: undefined method `each' for nil:NilClass 20) Error: SessionsHelperTest#test_current_user_returns_right_user_when_session_is_nil: ActiveRecord::StatementInvalid: Could not find table 'users' Error: SessionsHelperTest#test_current_user_returns_right_user_when_session_is_nil: NoMethodError: undefined method `each' for nil:NilClass 21) Error: UsersIndexTest#test_index_as_admin_including_pagination_and_delete_links: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersIndexTest#test_index_as_admin_including_pagination_and_delete_links: NoMethodError: undefined method `each' for nil:NilClass 22) Error: UsersIndexTest#test_index_as_non-admin: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersIndexTest#test_index_as_non-admin: NoMethodError: undefined method `each' for nil:NilClass 23) Error: SessionsControllerTest#test_should_get_new: ActiveRecord::StatementInvalid: Could not find table 'users' Error: SessionsControllerTest#test_should_get_new: NoMethodError: undefined method `each' for nil:NilClass 24) Error: UserTest#test_name_should_not_be_too_long: ActiveRecord::StatementInvalid: Could not find table 'users' 25) Error: UserTest#test_email_addresses_should_be_unique: ActiveRecord::StatementInvalid: Could not find table 'users' 26) Error: UserTest#test_email_should_not_be_too_long: ActiveRecord::StatementInvalid: Could not find table 'users' 27) Error: UserTest#test_should_be_valid: ActiveRecord::StatementInvalid: Could not find table 'users' 28) Error: UserTest#test_authenticated?_should_return_false_for_a_user_with_nil_digest: ActiveRecord::StatementInvalid: Could not find table 'users' 29) Error: UserTest#test_email_validation_should_reject_invalid_addresses: ActiveRecord::StatementInvalid: Could not find table 'users' 30) Error: UserTest#test_name_should_be_present: ActiveRecord::StatementInvalid: Could not find table 'users' 31) Error: UserTest#test_email_should_be_present: ActiveRecord::StatementInvalid: Could not find table 'users' 32) Error: SiteLayoutTest#test_layout_links: ActiveRecord::StatementInvalid: Could not find table 'users' Error: SiteLayoutTest#test_layout_links: NoMethodError: undefined method `each' for nil:NilClass 33) Error: UsersLoginTest#test_login_with_remembering: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersLoginTest#test_login_with_remembering: NoMethodError: undefined method `each' for nil:NilClass 34) Error: UsersLoginTest#test_login_with_valid_information_followed_by_logout: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersLoginTest#test_login_with_valid_information_followed_by_logout: NoMethodError: undefined method `each' for nil:NilClass 35) Error: UsersLoginTest#test_login_without_remembering: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersLoginTest#test_login_without_remembering: NoMethodError: undefined method `each' for nil:NilClass 36) Error: UsersLoginTest#test_login_with_invalid_information: ActiveRecord::StatementInvalid: Could not find table 'users' Error: UsersLoginTest#test_login_with_invalid_information: NoMethodError: undefined method `each' for nil:NilClass 36 runs, 0 assertions, 0 failures, 36 errors, 0 skips

###エラーに対して行ったこと
エラー文には、ActiveRecord::StatementInvalidとあったので、rails cでActiveRecordを確認したのですが、Usersはありました。また、本番用のテーブルがなのかと思い、本番用にマイグレーションも行ったのですが、エラー文は消えませんでした。

bundle exec rake RAILS_ENV=production db:migrate

どなたかお分かりになる方いましたら御回答の方宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

テストでは、test環境のデータベースを使用するので、

bundle exec rake RAILS_ENV=test db:migrate

を実行してみてはいかがでしょうか?

投稿2020/06/30 07:03

ok_minatomi

総合スコア3

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問