I`ve got these strange issues I dont know how to fix it. Please help me if you can.
Here is a testing result:
1) Admin can edit a hotel
Failure/Error: visit edit_admin_hotel_path(hotel)
URI::InvalidURIError:
bad URI(is not URI?):
# ./spec/requests/admin_spec.rb:32:in `block (2 levels) in <top (required)>'
2) Admin can edit a user
Failure/Error: visit edit_admin_user_path(admin)
URI::InvalidURIError:
bad URI(is not URI?):
# ./spec/requests/admin_spec.rb:54:in `block (2 levels) in <top (required)>'
rake routes shows me nice edit routes for users and hotels:
edit_admin_hotel GET /admin/hotels/:id/edit(.:format) admin/hotels#edit
edit_admin_user GET /admin/users/:id/edit(.:format) admin/users#edit
And everything works just fine if I start server and check it manually. So I have no idea where these issues comes from. Thanks for any help!
And my admin_spec.rb file:
require 'spec_helper'
describe "Admin" do
let(:admin) { FactoryGirl.create(:user) }
let(:hotel) { FactoryGirl.create(:hotel) }
before(:each) do
sign_up_as_admin admin
visit admin_hotels_path
end
subject { page }
it { expect(page).to have_content("Manage Hotels") }
it { expect(page).to have_content("Manage Users") }
it { expect(page).to have_link("Sign out") }
it { expect(page).to have_content("List of hotels") }
it { expect(page).to have_content("Hello, Admin") }
it "can add a hotel" do
click_link "Add Hotel"
expect(current_path).to eq(new_admin_hotel_path)
fill_in 'name', with: "TestHotel"
fill_in 'price', with: "666"
fill_in 'star_rating', with: "5"
expect { click_button "Submit" }.to change(Hotel,:count).by(1)
expect(current_path).to eq(admin_hotel_path(1))
end
it "can edit a hotel" do
visit edit_admin_hotel_path(hotel)
end
it "can delete a hotel" do
visit admin_hotel_path(hotel)
expect { click_link "Delete hotel" }.to change(Hotel,:count).by(-1)
#expect { click_link "Delete hotel" }.to redirect_to(admin_hotels_path)
end
it "can create a new user" do
click_link "Add User"
expect(current_path).to eq(new_admin_user_path)
expect(page).to have_content("Create New User")
fill_in "Name", :with => "user"
fill_in "Email", :with => "user#auser.com"
fill_in "Password", :with => "user.password"
fill_in "password_confirmation", :with => "user.password"
expect { click_button "Create User" }.to change(User,:count).by(1)
expect(current_path).to eq(admin_users_path)
end
it "can edit a user" do
visit edit_admin_user_path(admin)
end
end
Edit/update actions in users_controller.rb:
# GET admin/users/1/edit
def edit
#user = User.find(params[:id])
render "edit", status: 302
end
# PATCH/PUT admin/users/1
def update
#user = User.find(params[:id])
if #user.try(:update_attributes, user_params)
render "edit", notice: 'User was successfully updated.'
else
render action: 'edit'
end
end
private
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation, :admin)
end
And user/edit.html.erb:
<% provide(:title, "Edit user") %>
<h1>Update profile</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for([:admin, #user]) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirm Password" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Save changes" %>
<% end %>
<%= button_to 'Delete User', [:admin, #user], :data => { confirm: 'Are you sure?' }, method: :delete %>
</div>
</div>
Update 1:
I found out that these bad URI(is not URI?) errors also in hotel_controller and comment_controller while testing edit action. These errors in all of my controllers in edit actions and I dont know what cousing them :(
Your edit action is wrong:
def edit
#user = User.find(params[:id])
render "edit", status: 302
end
A 302 status means that the response is a redirect and that the Location header in the response contains the URI (relative or absolute) to redirect to. Capybara will be looking for this header and probably winds up trying to do URI.parse(nil).
It's not clear to me why you are setting the status here at all
In your spec_helper have you included the url_helpers?
config.include Rails.application.routes.url_helpers
Related
I have this integration test that is giving me errors that seem to have to do with fill_in
require 'rails_helper'
describe 'navigate' do
let(:user) {FactoryGirl.create(:user)}
let(:post) do
Post.create(date: Date.today, rationale: "Rationale", user_id: user.id)
end
before do
login_as(#user, :scope => :user)
end
describe 'index' do
before do
visit posts_path
end
it 'can be reached successfully' do
expect(page.status_code).to eq(200)
end
it 'has a title of Posts' do
expect(page).to have_content(/Posts/)
end
it 'has a list of posts' do
post1 = FactoryGirl.build_stubbed(:post)
post2 = FactoryGirl.build_stubbed(:second_post)
visit posts_path
expect(page).to have_content(/Rationale|content/)
end
it 'has a scope so that only post creators can see their posts' do
other_user = User.create(first_name: 'Non', last_name: 'Authorized', email: 'nonauth#example.com',
password: "password", password_confirmation: "password")
post_from_other_user = Post.create(date: Date.today, rationale: "This post shouldn't be seen",
user_id: other_user.id)
visit posts_path
expect(page).to_not have_content(/This post shouldn't be seen/)
end
end
describe 'new' do
it "has a link from the homepage" do
visit root_path
click_link("new_post_from_nav")
expect(page.status_code).to eq(200)
end
end
describe 'delete' do
it 'can be deleted' do
logout(:user)
delete_user = FactoryGirl.create(:user)
login_as(delete_user, :scope => :user)
post_to_delete = Post.create(date: Date.today, rationale: 'rationale', user_id: delete_user.id)
visit posts_path
click_link("delete_post_#{post_to_delete.id}_from_index")
expect(page.status_code).to eq(200)
end
end
describe 'creation' do
before do
visit new_post_path
end
it 'has a new form that can be reached' do
expect(page.status_code).to eq(200)
end
it 'can be created from a new form page' do
fill_in 'post[date]', with: Date.today
fill_in 'post[rationale]', with: "Some rationale"
click_on "Save"
expect(page).to have_content("Some rationale")
end
it 'will have a user associated with it' do
fill_in 'post[date]', with: Date.today
fill_in 'post[rationale]', with: "User Association"
click_on "Save"
expect(User.last.posts.last.rationale).to eq("User Association")
end
end
describe 'edit' do
it "can be edited" do
visit edit_post_path(post)
fill_in 'post[date]', with: Date.today
fill_in 'post[rationale]', with: "Edited content"
click_on "Save"
expect(page).to have_content("Edited content")
end
it "cannot be edited by a non authorized user" do
logout(:user)
non_authorized_user = FactoryGirl.create(:non_authorized_user)
login_as(non_authorized_user, :scope => :user)
visit edit_post_path(post)
expect(current_path).to eq(root_path)
end
end
end
I review the views/post/_form.html.erb file:
<%= form_for #post, class: "form-horizontal" do |f| %>
<% if #post.errors.any? %>
<% #post.errors.full_messages.each do |error| %>
<%= js add_gritter(error, title: "Overtime App Notification", sticky: false, image: :notice) %>
<% end %>
<% end %>
<div class="form-group">
<%= f.label :date, class: "col-sm-2 control-label" %>
<%= f.date_field :date, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :rationale, class: "col-sm-2 control-label" %>
<%= f.text_area :rationale, class: "form-control" %>
</div>
<%= render partial: 'status', locals: {f: f} if current_user.type == 'AdminUser' %>
<%= f.submit 'Save', class: 'btn btn-primary btn-block' %>
<% end %>
I can't tell what is going wrong here. If I inspect element, it's there:
This is my post.rb model file:
class Post < ActiveRecord::Base
enum status: {submitted: 0, approved: 1, rejected: 2}
belongs_to :user
validates_presence_of :date, :rationale
scope :posts_by, ->(user) {where(user_id: user.id)}
end
The tests were passing yesterday, not sure what happened.
You're calling login_as with #user, but #user is never defined, you probably want login_as(user).
Always try to retrace your steps, if something was working before, think about what code you introduced between the last time it worked and when it began failing.
Checking status codes is generally a bad smell for feature tests, just check for things the user can see.
Don't use the eq matcher with current_path instead use the have_current_path matcher provided by Capybara.
I ran rspec on some tests I created and here is the output I received.
Failures:
1) User pages signup with valid information should create a user
Failure/Error: fill_in "Name", with: "Example User"
Capybara::ElementNotFound:
Unable to find field "Name"
# ./spec/requests/user_pages_spec.rb:18:in `block (4 levels) in <top (required)>'
2) User pages signup with invalid information should not create a user
Failure/Error: expect { click_button submit }.not_to change(User, :count)
Capybara::ElementNotFound:
Unable to find button "Create my account"
# ./spec/requests/user_pages_spec.rb:12:in `block (5 levels) in <top (required)>'
# ./spec/requests/user_pages_spec.rb:12:in `block (4 levels) in <top (required)>'
Here is my rspec code for user_pages_spec.rb
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup" do
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
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_content(user.name) }
it { should have_title(user.name) }
end
describe "signup page" do
before { visit signup_path }
it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
end
Now, to show you my html page
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for(#user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.text_field :password %>
<%= f.label :password_confirmation %>
<%= f.text_field :password_confirmation %>
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
</div>
</div>
In this example, clearly you can find a text-field named "Name" and a button "Create my account". I'm baffled at how rspec saw errors.
Can anyone help me?
Edit: Maybe it didn't work because I haven't defined a create method in my UsersController
class UsersController < ApplicationController
def new
#user = User.new
end
def show
#user = User.find(params[:id])
end
end
You are not actually going to any page before you start trying to fill in the form.
At the beginning of the test you will need a visit statement. Something like:
describe "User pages" do
subject { page }
describe "signup" do
before { visit new_user_path }
...
I'm working through Michael Hartl's Rails tutorial, and I'm running into an issue in section 7.3.3. I receive this error message:
ArgumentError in Users#new
Showing /Users/Anuraag/rails_projects/sample_app/app/views/users/new.html.erb where line #6 raised:
First argument in form cannot contain nil or be empty
when I run the following rspec:
bundle exec rspec spec/requests/user_pages_spec.rb -e "signup with invalid information"
at the following line:
<%= form_for(#user) do |f| %>
Here is my code. Please also let me know how I should improve this question if I'm not framing it well: I'm pretty new to StackOverflow as well
app/views/users/new.html.erb:
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for(#user) do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
</div>
</div>
app/assets/controllers/users_controller.rb:
class UsersController < ApplicationController
def show
#user = User.find(params[:id])
end
def create
#user = User.new(user_params)
if #user.save
# Handle a successful save.
else
render 'new'
end
end
private
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation)
end
end
spec/requests/user_pages_spec.rb
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_content(user.name) }
it { should have_title(user.name) }
end
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
end
In your new.html.erb you have specified form_for(#user) that means you need to have some value in instance variable #user before calling the new action.
You can do it in two ways :
one way is define an action new in your controller which would be called before rendering your new.html.erb layout. For eg:
def new
#user = User.new
end
other way is that in your form itself you could specify something like
<%= form_for(User.new) do |f| %>
Defining it in your new action is more standard way of doing it.
The order of actions in controller file matters. I had the same error until I figure out the problem on order of action methods.
Example.
Controller file
def edit
#post = Post.find(params[:id])
end
def update
end
private
def post_params
params.require(:post).permit(:title, :body)
end
I was working on edit action and was getting same error as you. The problem was I have written the edit action under private action. once I changed the order of this actions. It worked like a charm.
What I was trying to achieve ?
I was trying to take the values of post instance variable and use it into html form.
I dont see a new action on you controller.
def new
#user = User.new
end
I maybe made indirectly, but it couldn't hurt defining it yourself.
From you title that may be why the #user variable is nil, it wasn't defined.
This is my first post here so hopefully I have followed the guide but if there is a better way to post, feel free to point me in the right direction - I learn fast.
I am new to rails and working through the Hartl Rails Tutorial. I searched google and here for the solution but can't seem to locate an answer to why the tests fail on click_button "Sign in".
I also went through the rails casts video Railscasts #270 Authentication
What am I missing so I can get these tests to pass? Any help would be greatly appreciated.
All the test pass if i use the form_for but fail when I use form_tag in .sessions/new.html.erb. The Sign_in page still renders correctly but once I try to sign in, the web page shows an error on:
def create
user = User.find_by(email: params[:session][:email].downcase)
Here is the exercise that I am trying to accomplish - Chapter 8, section 8.5, exercise 1:
8.5 Exercises
Refactor the signin form to use form_tag in place of form_for. Make
sure the test suite still passes. Hint: See the RailsCast on
authentication in Rails 3.1, and note in particular the change in
the structure of the params hash.
.sessions/new.html.erb
<% provide(:title, "Sign in") %>
<h1>Sign in</h1>
<div class="row">
<div class="span6 offset3">
<%= form_tag sessions_path do %>
<%= label_tag :email %>
<%= text_field :email, params[:email] %>
<%= label_tag :password %>
<%= password_field_tag :password %>
<%= submit_tag "Sign in", class: "btn btn-large btn-primary" %>
<% end %>
<!--
<%= form_for(:session, url: sessions_path) do |f| %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
<% end %>
-->
<p>New user? <%= link_to "Sign up now!", signup_path %></p>
</div>
</div>
This is the output of rspec spec/
> Failures:
1) Authentication signin with invalid information
Failure/Error: before { click_button "Sign in" }
NoMethodError:
undefined method `[]' for nil:NilClass
# ./app/controllers/sessions_controller.rb:7:in `create'
# ./spec/requests/authentication_pages_spec.rb:19:in `block (4 levels) in <top (required)>'
2) Authentication signin with invalid information
Failure/Error: before { click_button "Sign in" }
NoMethodError:
undefined method `[]' for nil:NilClass
# ./app/controllers/sessions_controller.rb:7:in `create'
# ./spec/requests/authentication_pages_spec.rb:19:in `block (4 levels) in <top (required)>'
3) Authentication signin with invalid information after visiting another page
Failure/Error: before { click_button "Sign in" }
NoMethodError:
undefined method `[]' for nil:NilClass
# ./app/controllers/sessions_controller.rb:7:in `create'
# ./spec/requests/authentication_pages_spec.rb:19:in `block (4 levels) in <top (required)>'
4) Authentication signin with valid information
Failure/Error: fill_in "Email", with: user.email.upcase
Capybara::ElementNotFound:
Unable to find field "Email"
# ./spec/requests/authentication_pages_spec.rb:41:in `block (4 levels) in <top (required)>'
5) Authentication signin with valid information
Failure/Error: fill_in "Email", with: user.email.upcase
Capybara::ElementNotFound:
Unable to find field "Email"
# ./spec/requests/authentication_pages_spec.rb:41:in `block (4 levels) in <top (required)>'
6) Authentication signin with valid information
Failure/Error: fill_in "Email", with: user.email.upcase
Capybara::ElementNotFound:
Unable to find field "Email"
# ./spec/requests/authentication_pages_spec.rb:41:in `block (4 levels) in <top (required)>'
7) Authentication signin with valid information
Failure/Error: fill_in "Email", with: user.email.upcase
Capybara::ElementNotFound:
Unable to find field "Email"
# ./spec/requests/authentication_pages_spec.rb:41:in `block (4 levels) in <top (required)>'
8) Authentication signin with valid information followed by signout
Failure/Error: fill_in "Email", with: user.email.upcase
Capybara::ElementNotFound:
Unable to find field "Email"
# ./spec/requests/authentication_pages_spec.rb:41:in `block (4 levels) in <top (required)>'
.....
./spec/requests/authentication_pages_spec.rb
require 'spec_helper'
describe "Authentication" do
subject { page }
describe "signin page" do
before { visit signin_path }
it { should have_content('Sign in') }
it { should have_title('Sign in') }
end
#Testing for sign in failure
describe "signin" do
before { visit signin_path }
describe "with invalid information" do
before { click_button "Sign in" }
it { should have_title('Sign in') }
# This uses Capabara have_selector method
# dot means "class" in CSS testing for div tag with classes "alert"
# and "alert-error" and the error message contains "invalid"
it { should have_selector('div.alert.alert-error', text: 'Invalid') }
describe "after visiting another page" do
before { click_link "Home" }
it { should_not have_selector('div.alert.alert-error') }
end
end
# Testing for sign success
describe "with valid information" do
# This is using FactoryGirl gem
let(:user) { FactoryGirl.create(:user) }
before do
fill_in "Email", with: user.email.upcase
fill_in "Password", with: user.password
click_button "Sign in"
end
# Uses Capybara's have_link method - takes arguments as text
# of the link and optional :href
it { should have_title(user.name) }
it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Sign out', href: signout_path) }
it { should_not have_link('Sign in', href: signin_path) }
describe "followed by signout" do
before { click_link "Sign out" }
it { should have_link('Sign in') }
end
end
end
end
./app/controllers/sessions_controller.rb
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
# Sign the user in and redirect to the user's show page.
sign_in user
redirect_to user
else
# Flash [:error] comes from bootstap CSS
flash.now[:error] = 'Invalid email/password combination'
# This line activates the link signin to show the page view new.html.erb
render 'new'
end
end
def destroy
sign_out
redirect_to root_url
end
end
this works for me
new.html.erb
<% provide(:title, "Sign in") %>
<h1>Sign in</h1>
<div class="row">
<div class="span6 offset3">
<%= form_tag sessions_path do %>
<%= label_tag :email %>
<%= text_field_tag :email %>
<%= label_tag :password %>
<%= password_field_tag :password %>
<%= submit_tag "Sign in", class: "btn btn-large btn-primary" %>
<% end %>
<p>New user? <%= link_to "Sign up now!", signup_path %></p>
</div>
</div>
sessions_controller.erb
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by(email: params[:email].downcase)
if user && user.authenticate(params[:password])
sign_in user
redirect_to user
else
flash.now[:error] = 'Invalid email/password combination'
render 'new'
end
end
def destroy
sign_out
redirect_to root_url
end
end
Please tell me if it works for you.
Thanks
In the exercise is mentioned that the structure of the params hash is changed. You need to edit this in the controller like following (this works in my case). It does not work currently because the params aren't accessible.
User.find_by_email(params[:email].downcase) and authenticate(params[:password]) are modified. If somebody can elaborate why this is feel free to do so.
An extract of my code you can find here:
def create
user = User.find_by_email(params[:email].downcase)
if user && user.authenticate(params[:password])
# Sign in the user and redirect to user show page
sign_in user
redirect_to user
else
flash.now[:error] = 'Invalid email/password combination'
render 'new'
end
end
I'm getting the following error when testing the sign up page for the ruby-on-rails tutorial:
Failures:
1) User pages signup with valid information should create a user
Failure/Error: expect { click_button submit }.to change(User, :count).by(1)
ActionView::MissingTemplate:
Missing template users/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "/Users/Fif/rails_projects/sample_app/app/views"
# (eval):2:in `click_button'
# ./spec/requests/user_pages_spec.rb:43:in `block (5 levels) in <top (required)>'
# ./spec/requests/user_pages_spec.rb:43:in `block (4 levels) in <top (required)>'
Finished in 0.76918 seconds
35 examples, 1 failure
Failed examples:
rspec ./spec/requests/user_pages_spec.rb:42 # User pages signup with valid information should create a user
I'm not sure what the problem is, and I've gone over the code several times to make sure that it matches the examples in the book. I'm pretty sure that it has to do with the new.html.erb file
user_pages_spec.rb
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
end
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_selector('h1', text: user.name) }
it { should have_selector('title', text: user.name) }
end
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
end
new.html.erb
<%= provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for(#user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
</div>
</div>
users_controller.rb
class UsersController < ApplicationController
def show
#user = User.find(params[:id])
end
def new
#user = User.new
end
def create
#user = User.new(params[:user])
if #user.save
# Handle a successful save.
else
render 'new'
end
end
end
Short Answer:
It is not supposed to work (yet).
Continue the tutorial, the answer will come in section 7.4;
Slightly longer Answer:
When you fill in the form and push the submit-button, the create-event in the users_controller gets triggered. Since you don't have any code there (yet), Rails assumes that you just want to render create.html.erb, which doesn't exist (and never will).
In order to get this to work immediately, you have to add redirect_to #user right underneath if #user.save. Check Listing 7.25;
Jump down to the bottom of the tutorial and the question is answered. Include redirect_to #user right under your #Handle a successful save.