title: Using redirect_to with a specific ActiveRecord object to create a link to that object
body: <p>I'm going through Michael Hartl's tutorial at <a href="http://ruby.railstutorial.org/" rel="noreferrer">http://ruby.railstutorial.org/</a>. It's basically a message board app where Users can post Messages and others can leave Replies.  Right now I'm creating <code>Users</code>. Inside the <code>UsersController</code> things look like this:</p>
  
  <pre><code>    class UsersController &lt; ApplicationController
        def new
          @user = User.new
        end
  
        def show
          @user = User.find(params[:id])
        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
  </code></pre>
  
  <p>The author says that the following lines are equivalent. Which makes sense to me:</p>
  
  <pre><code>    @user = User.new(params[:user])
      is equivalent to
      @user = User.new(name: "Foo Bar", email: "foo@invalid",
               password: "foo", password_confirmation: "bar")
  </code></pre>
  
  <p><code>redirect_to @user</code> redirects to <code>show.html.erb</code>. How exactly does that work? How does it know to go to <code>show.html.erb</code>?</p>