Michael Hartl Rails Tutorial chapter 7 error Action not found in UsersController

railstutorial.org, rspec, ruby, ruby-on-rails

Solution

The tests shouldn't be passing at that point. Keep following the tutorial and you'll see how it works.

Problem

I'm following Michael Hartl's Rails Tutorial at the moment and I've managed to 7.22 without any major hitches. However I'm stumped by the output from the testing which says: ``` Failures: 1) UserPages signup with invalid information should not create a user Failure/Error: expect{click_button submit }.not_to change(User, :count) AbstractController::ActionNotFound: The action 'create' could not be found for UsersController # (eval):2:in `click_button' # ./spec/requests/user_pages_spec.rb:29:in `block (5 levels) in <top (required)>' # ./spec/requests/user_pages_spec.rb:29:in `block (4 levels) in <top (required)>' 2) UserPages signup with valid information should create a user Failure/Error: expect{click_button submit}.to change(User, :count).by(1) AbstractController::ActionNotFound: The action 'create' could not be found for UsersController # (eval):2:in `click_button' # ./spec/requests/user_pages_spec.rb:42:in `block (5 levels) in <top (required)>' # ./spec/requests/user_pages_spec.rb:42:in `block (4 levels) in <top (required)>' Finished in 0.7718 seconds 6 examples, 2 failures ``` I've added the following to my users controllers page as instructed by the tutorial: ``` class UsersController < ApplicationController def show @user = User.find(params[:id]) end def new @user = User.new end end ``` but it still doesn't seem to work. I've tried adding a create method but that just throws back a missing template error... In case it helps here's the output of the rake routes command: ``` ~/dev/rails/sample_app$ rake routes users GET /users(.:format) users#index POST /users(.:format) users#create new_user GET /users/new(.:format) users#new edit_user GET /users/:id/edit(.:format) users#edit user GET /users/:id(.:format) users#show PUT /users/:id(.:format) users#update DELETE /users/:id(.:format) users#destroy root / static_pages#home signup /signup(.:format) users#new help /help(.:format) static_pages#help about /about(.:format) static_pages#about contact /contact(.:format) static_pages#contact ``` In response to a comment, the tests which are failing are: ``` describe "signup" do before{ visit signup_path } let(:submit) {"Create my account"} describe "with invalid information" do it "should not create a user" do expect{click_button submit }.not_to change(User, :count) end end describe "with valid information" do before do fill_in "Name", with: "Example User" fill_in "Email", with: "user@example.com" fill_in "Password", with: "foobar" fill_in "Confirmation", with: "foobar" end it "should create a user" do expect{click_button submit}.to change(User, :count).by(1) end end end ``` Thanks in advance for any advice!

Original source