railsチュートリアルの7.3.4をやっています。
初心者ながらにわからないところも自力で解決してみようと頑張っているのですが、テストがなぜか通りません。
エラーコードは以下の通りです。
UsersSignupTest#test_invalid_signup_information: ActionView::Template::Error: undefined method `users_path' for #<#<Class:0x00007fbe7c2f3e28>:0x00007fbe7c2ef990> Did you mean? user_path app/views/user/new.html.erb:7:in `_app_views_user_new_html_erb___1484384119590120163_70228051993880' test/integration/users_signup_test.rb:6:in `block in <class:UsersSignupTest>
これを読むと、『「users_path」と書いてしまっているから「user_path」に直してね』ということなのですが、実際に書いたソースがこちらです。
equire 'test_helper' class UsersSignupTest < ActionDispatch::IntegrationTest test "invalid signup information" do get signup_path assert_no_difference 'User.count' do post user_path, params: { user: { name: "", email: "user@invalid", password: "foo", password_confirmation: "bar" } } end assert_template 'user/new' end end
どこにも「users_path」なんて書いてないんです。
どういうことなのでしょうか。。。
ご教授願います。
以下がbundle exec rake routesの結果です
Prefix Verb URI Pattern Controller#Action user_new GET /user/new(.:format) user#new root GET / satic_pages#home help GET /help(.:format) satic_pages#help about GET /about(.:format) satic_pages#about contact GET /contact(.:format) satic_pages#contact signup GET /signup(.:format) user#new user_index GET /user(.:format) user#index POST /user(.:format) user#create new_user GET /user/new(.:format) user#new edit_user GET /user/:id/edit(.:format) user#edit user GET /user/:id(.:format) user#show PATCH /user/:id(.:format) user#update PUT /user/:id(.:format) user#update DELETE /user/:id(.:format) user#destroy
次がapp/view/user/new.html.erbです
<% provide(:title,'Sign up') %> <h1>新規登録</h1> <p>新しくアカウントつくるとこやで。</p> <div class="row"> <div class="col-md-6 col-md-offset-3"> <%= form_for(@user) do |f| %> <%= render 'shared/error_messages' %> <%= f.label :name %> <%= f.text_field :name, class: 'form-control' %> <%= f.label :email %> <%= f.email_field :email, class: 'form-control' %> <%= f.label :password %> <%= f.password_field :password, class: 'form-control' %> <%= f.label :password_confirmation, "Confirmation" %> <%= f.password_field :password_confirmation, class: 'form-control' %> <%= f.submit "Create my account", class: "btn btn-primary" %> <% end %> </div> </div>
お願いします。
app/views/user/new.html.erb のソース(7行目付近)と、`bundle exec rake routes` コマンドを実行した結果を貼っていただけませんか?