title: undefined method `username' for nil:NilClass when signing up and signing in
body: <p>Whenever I try to log in and sign up, I am hit with this error:</p>
  
  <p>undefined method `username' for nil:NilClass</p>
  
  <p>on these two lines:</p>
  
  <pre><code>&lt;strong&gt;&lt;%= @user.username %&gt;&lt;/strong&gt; &lt;br&gt;
  &lt;strong&gt;&lt;%= @user.name %&gt;&lt;/strong&gt;
  </code></pre>
  
  <p>Here is the full error from the server's output:</p>
  
  <pre><code>User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."username" = 'sign_in' LIMIT 1
    Rendered users/show.html.erb within layouts/application (2.1ms)
  Completed 500 Internal Server Error in 7ms
  
  ActionView::Template::Error (undefined method `username' for nil:NilClass):
      1: &lt;strong&gt;&lt;%= @user.username %&gt;&lt;/strong&gt; &lt;br&gt;
      2: &lt;strong&gt;&lt;%= @user.name %&gt;&lt;/strong&gt;
      3: &lt;%= debug @user %&gt;
      4: 
    app/views/users/show.html.erb:1:in `_app_views_users_show_html_erb__1133891108745893964_2164088020'
  </code></pre>
  
  <p>Here are my routes:</p>
  
  <pre><code>Stynyl::Application.routes.draw do
    resources :things
    resources :users, only: [:show]
  
    devise_for :users
    get '/about', to: 'pages#about'
    root 'things#index'
  end
  </code></pre>
  
  <p>Here is my user show view</p>
  
  <pre><code>&lt;strong&gt;&lt;%= @user.username %&gt;&lt;/strong&gt; &lt;br&gt;
  &lt;strong&gt;&lt;%= @user.name %&gt;&lt;/strong&gt;
  
  
  
  &lt;div id="things" class="transitions-enabled"&gt;
    &lt;% @user.things.each do |thing| %&gt;
      &lt;div class='panel panel default'&gt;
      &lt;div class="box"&gt;
        &lt;%= link_to image_tag(thing.image.url(:medium)), thing %&gt;
        &lt;div class='panel-body'&gt;
        &lt;strong&gt;&lt;p&gt;&lt;%= thing.title %&gt;&lt;/p&gt;&lt;/strong&gt;
        &lt;p&gt;&lt;%= thing.description %&gt;&lt;/p&gt;
        By &lt;%= link_to thing.user.username, thing.user %&gt;
  
        &lt;% if thing.user == current_user %&gt;
          &lt;%= link_to edit_thing_path(thing) do %&gt;
          &lt;span class='glyphicon glyphicon-edit'&gt;&lt;/span&gt; Edit
        &lt;% end %&gt;
        &lt;%= link_to thing_path(thing), method: :delete, data: { confirm: 'Are you sure?' } do %&gt;
          &lt;span class='glyphicon glyphicon-trash'&gt;&lt;/span&gt; Delete
        &lt;% end %&gt;
        &lt;/div&gt;
        &lt;% end %&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my UsersController file:</p>
  
  <pre><code>class UsersController &lt; ApplicationController
    def show
      @user = User.find_by_username(params[:id])
    end
  end
  </code></pre>
  
  <p>Output of rake routes:</p>
  
  <pre><code>            Prefix Verb   URI Pattern                    Controller#Action
                    things GET    /things(.:format)              things#index
                           POST   /things(.:format)              things#create
                 new_thing GET    /things/new(.:format)          things#new
                edit_thing GET    /things/:id/edit(.:format)     things#edit
                     thing GET    /things/:id(.:format)          things#show
                           PATCH  /things/:id(.:format)          things#update
                           PUT    /things/:id(.:format)          things#update
                           DELETE /things/:id(.:format)          things#destroy
                     users POST   /users(.:format)               users#create
                  new_user GET    /users/new(.:format)           users#new
                      user GET    /users/:id(.:format)           users#show
          new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
              user_session POST   /users/sign_in(.:format)       devise/sessions#create
      destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
             user_password POST   /users/password(.:format)      devise/passwords#create
         new_user_password GET    /users/password/new(.:format)  devise/passwords#new
        edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                           PATCH  /users/password(.:format)      devise/passwords#update
                           PUT    /users/password(.:format)      devise/passwords#update
  cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
         user_registration POST   /users(.:format)               devise/registrations#create
     new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
    edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                           PATCH  /users(.:format)               devise/registrations#update
                           PUT    /users(.:format)               devise/registrations#update
                           DELETE /users(.:format)               devise/registrations#destroy
                     about GET    /about(.:format)               pages#about
                      root GET    /                              things#index
  </code></pre>
  
  <p><strong>Edits</strong></p>
  
  <ol>
  <li>I also noticed that when I delete all of the code from the User show view, I can get to the signup and login pages, but they are <strong>blank</strong>. Can we safely guarantee that the problem is in the view? I'm so perplexed at how something in the show view can affect the ability to sign in and sign up!</li>
  <li>I have also observed that when I add content to the users show view, it appears on the sign up and login pages. What on earth is going on?</li>
  </ol>