title: before_action in user controller rendering error: NoMethodError in Users#show
body: <p>I am following Michael Hartl's Rails guide (on chapter 9). When I try to access the page corresponding the the user's profile, the browser displays the following error messages:</p>
  
  <pre><code> NoMethodError in Users#show
  
  Showing /home/jonathan/Desktop/railsTut/sample_app/app/views/users/show.html.erb where line #1 raised:
  
  undefined method `name' for nil:NilClass
  
  Extracted source (around line #1):
  
  1: &lt;% provide(:title, @user.name) %&gt;
  2: &lt;div class="row"&gt;
  3:   &lt;aside class="span4"&gt;
  4:     &lt;section&gt;
  
  Rails.root: /home/jonathan/Desktop/railsTut/sample_app
  </code></pre>
  
  <p>Here is my users_controller.rb </p>
  
  <pre><code>class UsersController &lt; ApplicationController
    before_action :signed_in_user, only: [:edit, :update]
  
    def show
      @user = User.find(params[:id])
      end
  
    def new
      @user = User.new
    end
  
    def create
      @user = User.new(params[:user])    # Not the final implementation!
      if @user.save
       sign_in @user
       flash[:success] = "Welcome to the Sample App!"
       redirect_to @user
      else
        render 'new'
      end
    end
  
    def edit
      @user = User.find(params[:id])
    end
  
    def update
      @user = User.find(params[:id])
      if @user.update_attributes(params[:user])
           flash[:success] = "Profile updated"
           sign_in @user
           redirect_to @user
        else
             render 'edit'
        end
      end
  
    def destroy
   User.find(params[:id]).destroy
      flash[:success] = "User destroyed."
      redirect_to users_url
      end
  
  private
  
    def user_params
      params.require(:user).permit(:name, :email, :password, :password_confirmation)
      end
  
  
    # Before filters
  
    def signed_in_user
      unless signed_in?
          store_location
          redirect_to signin_url, notice: "Please sign in."
      end
   end
  end
  </code></pre>
  
  <p>The page loads fine without the line:</p>
  
  <pre><code>before_action :signed_in_user, only: [:edit, :update]
  </code></pre>
  
  <p>But with it's inclusion things go wrong and I can't figure out why. </p>
  
  <p>Also, here is the routes.rb</p>
  
  <pre><code>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'
  
  end
  </code></pre>
  
  <p>Any help is appreciated!</p>