NoMethodError in UsersController#create
- by Mike DeVerna
I'm getting stuck on an error I'm getting when signing up a new user in Michael Hart's Ruby on Rails Tutorial. I'm new to rails but I've been searching for hours and can't seem to find anything to figure out the issue. My initial thought is that it's specific to the following line:
redirect_to @user
This is my file for users_controller.rb
#!/bin/env ruby
# encoding: utf-8
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
flash[:success] = "Welcome to the Sample App!"
?????????????? redirect_to @user
else
render 'new'
end
end
end
This is the error message I get:
NoMethodError in UsersController#create
undefined method `??????????????' for # Rails.root: /Users/mikedeverna/Documents/rails_projects/sample_app
Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:18:in `create'
Here is the code in my routes.rb file:
SampleApp::Application.routes.draw do
resources :users
resources :sessions, only: [:new, :create, :destroy]
root to: 'static_pages#home'
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'