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

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

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

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

テスト駆動開発

テスト駆動開発は、 プログラム開発手法の一種で、 プログラムに必要な各機能をテストとして書き、 そのテストが動作する必要最低限な実装を行い コードを洗練させる、といったサイクルを繰り返す手法の事です。

Q&A

1回答

1010閲覧

Railsチュートリアル 第10章 リスト10.23にてテストが通りません

sn.jr

総合スコア53

Ruby on Rails

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

テスト駆動開発

テスト駆動開発は、 プログラム開発手法の一種で、 プログラムに必要な各機能をテストとして書き、 そのテストが動作する必要最低限な実装を行い コードを洗練させる、といったサイクルを繰り返す手法の事です。

0グッド

0クリップ

投稿2019/11/24 02:20

2人目のユーザーarcherをtest/fixtures/users.ymlに追加すると2つ目のようなエラーが出てしまいます。サイト自体は動くのですが、なぜこのようなエラーが出てしまうのかが気になります。またこのエラーは今後railsチュートリアルを進めていく上で邪魔になってこないか心配です。どなたかご教授していただけると幸いです。

test/fixtures/users.yml

michael: name: Michael Example email: michael@example.com password_digest: <%= User.digest('password') %> archer: name: Sterling Archer email: duchess@example.gov password_digest: <%= User.digest('password') %>

rails test後の内容 本来ならerrorなく進めることができるところらしい

1) Error: StaticPagesControllerTest#test_should_get_about: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: StaticPagesControllerTest#test_should_get_about: NoMethodError: undefined method `each' for nil:NilClass 2) Error: StaticPagesControllerTest#test_should_get_contact: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: StaticPagesControllerTest#test_should_get_contact: NoMethodError: undefined method `each' for nil:NilClass 3) Error: StaticPagesControllerTest#test_should_get_home: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: StaticPagesControllerTest#test_should_get_home: NoMethodError: undefined method `each' for nil:NilClass 4) Error: StaticPagesControllerTest#test_should_get_help: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: StaticPagesControllerTest#test_should_get_help: NoMethodError: undefined method `each' for nil:NilClass 5) Error: UsersSignupTest#test_invalid_signup_information: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersSignupTest#test_invalid_signup_information: NoMethodError: undefined method `each' for nil:NilClass 6) Error: UsersSignupTest#test_valid_signup_information: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersSignupTest#test_valid_signup_information: NoMethodError: undefined method `each' for nil:NilClass 7) Error: UserTest#test_authenticated?_should_return_false_for_a_user_with_nil_digest: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 8) Error: UserTest#test_email_validation_should_reject_invalid_addresses: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 9) Error: UserTest#test_email_should_be_present: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 10) Error: UserTest#test_name_should_not_be_too_long: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 11) Error: UserTest#test_should_be_valid: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 12) Error: UserTest#test_password_should_have_a_minimum_length: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 13) Error: UserTest#test_name_should_be_present: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 14) Error: UserTest#test_email_should_not_be_too_long: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 15) Error: UserTest#test_password_should_be_present_(nonblank): ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 16) Error: UserTest#test_email_addresses_should_be_unique: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 17) Error: UserTest#test_email_validation_should_accept_valid_addresses: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". 18) Error: UsersLoginTest#test_login_with_remembering: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersLoginTest#test_login_with_remembering: NoMethodError: undefined method `each' for nil:NilClass 19) Error: UsersLoginTest#test_login_with_valid_information: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersLoginTest#test_login_with_valid_information: NoMethodError: undefined method `each' for nil:NilClass 20) Error: UsersLoginTest#test_login_with_valid_information_followed_by_logout: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersLoginTest#test_login_with_valid_information_followed_by_logout: NoMethodError: undefined method `each' for nil:NilClass 21) Error: UsersLoginTest#test_login_without_remembering: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersLoginTest#test_login_without_remembering: NoMethodError: undefined method `each' for nil:NilClass 22) Error: UsersLoginTest#test_login_with_invalid_information: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersLoginTest#test_login_with_invalid_information: NoMethodError: undefined method `each' for nil:NilClass 23) Error: SessionsHelperTest#test_current_user_returns_nil_when_remember_digest_is_wrong: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: SessionsHelperTest#test_current_user_returns_nil_when_remember_digest_is_wrong: NoMethodError: undefined method `each' for nil:NilClass 24) Error: SessionsHelperTest#test_current_user_returns_right_user_when_session_is_nil: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: SessionsHelperTest#test_current_user_returns_right_user_when_session_is_nil: NoMethodError: undefined method `each' for nil:NilClass 25) Error: SiteLayoutTest#test_layout_links: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: SiteLayoutTest#test_layout_links: NoMethodError: undefined method `each' for nil:NilClass 26) Error: UsersEditTest#test_successful_edit: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersEditTest#test_successful_edit: NoMethodError: undefined method `each' for nil:NilClass 27) Error: UsersEditTest#test_unsuccessful_edit: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersEditTest#test_unsuccessful_edit: NoMethodError: undefined method `each' for nil:NilClass 28) Error: SessionsControllerTest#test_should_get_new: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: SessionsControllerTest#test_should_get_new: NoMethodError: undefined method `each' for nil:NilClass 29) Error: UsersControllerTest#test_should_get_new: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersControllerTest#test_should_get_new: NoMethodError: undefined method `each' for nil:NilClass 30) Error: UsersControllerTest#test_should_redirect_update_when_not_logged_in: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersControllerTest#test_should_redirect_update_when_not_logged_in: NoMethodError: undefined method `each' for nil:NilClass 31) Error: UsersControllerTest#test_should_redirect_edit_when_not_logged_in: ActiveRecord::Fixture::FixtureError: table "users" has no column named "archer". Error: UsersControllerTest#test_should_redirect_edit_when_not_logged_in: NoMethodError: undefined method `each' for nil:NilClass 31 runs, 0 assertions, 0 failures, 31 errors, 0 skips

##やってみたこと
rails db:migrate:resetをしてもともと登録してあった自分の名前、メールアドレスを消した。

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

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

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

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

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

guest

回答1

0

初めまして。
自分も同じエラーで悩みましたが、下記の内容で解決できました。

users.ymlファイルで追加したarcher:〜の部分で、
下記の様に「archer:」の先頭にTABが入っていないでしょうか?

michael: name: Michael Example email: michael@example.com password_digest: <%= User.digest('password') %> archer: name: Sterling Archer email: duchess@example.gov password_digest: <%= User.digest('password') %>

「archer:」の先頭にTABを削除すれば大丈夫だと思います。

michael: name: Michael Example email: michael@example.com password_digest: <%= User.digest('password') %> archer: name: Sterling Archer email: duchess@example.gov password_digest: <%= User.digest('password') %>

投稿2020/05/10 00:14

shimazaki

総合スコア13

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問