title: How do I define a custom URL for a form confirmation page?
body: <p>I am creating a basic product landing page with Rails in which users can enter their email address to be notified when the product launches. (Yes, there are services/gems etc that could do this for me, but I am new to programming and want to build it myself to learn rails.)</p>
  
  <p>On successful submit of the form, I would like to redirect to a custom '/thanks' page in which I thank users for their interest in the product (and also encourage them to complete a short survey.)</p>
  
  <p>Currently, successful submits are displayed at "/invites/:id/" eg "invites/3" which I do not want since it exposes the number of invites that have been submitted.  I would like to instead redirect all successful submits to a "/thanks" page.</p>
  
  <p>I have attempted to research "rails custom URLs" but have not been able to find anything that works.  The closest I was able to find was this <a href="https://stackoverflow.com/questions/7728304/rails-3-1-how-to-redirect-properly-with-custom-routes">Stackoverflow post on how to redirect with custom routes</a> but did not fully understand the solution being recommended.  I have also tried reading the <a href="http://guides.rubyonrails.org/routing.html" rel="nofollow noreferrer">Rails Guide on Routes</a> but am new to this and did not see anything that I understood to allow for creating a custom URL.</p>
  
  <p>I have placed my thanks message which I would like displayed on successful form submit in "views/invites/show.html.haml"
  </p>
  
  <p><strong>My Routes file</strong></p>
  
  <pre class="lang-rb prettyprint-override"><code>resources :invites
  root :to =&gt; 'invites#new'
  </code></pre>
  
  <p>I tried inserting in routes.rb:</p>
  
  <pre class="lang-rb prettyprint-override"><code>post "/:thanks" =&gt; "invites#show", :as =&gt; :thanks
  </code></pre>
  
  <p>But I don't know if this would work or how I would tell the controller to redirect to :thanks</p>
  
  <p><strong>My controller</strong> (basically vanilla rails, only relevant actions included here): </p>
  
  <pre class="lang-rb prettyprint-override"><code>def show
      @invite = Invite.find(params[:id])
      show_path = "/thanks"
  
      respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @invite }
      end
    end
  
  # GET /invites/new
  # GET /invites/new.json
  def new
    @invite = Invite.new
  
    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @invite }
    end
   end
  
   # POST /invites
   # POST /invites.json
   def create
     @invite = Invite.new(params[:invite])
  
     respond_to do |format|
       if @invite.save
         format.html { redirect_to @invite }
         #format.js { render :action =&gt; 'create_success' }
         format.json { render json: @invite, status: :created, location: @invite }
       else
         format.html { render action: "new" }
         #format.js { render :action =&gt; 'create_fail' }
         format.json { render json: @invite.errors, status: :unprocessable_entity }
       end
     end
   end
  </code></pre>
  
  <p>It would seem as if creating a standard URL for displaying a confirmation would be relatively straightforward.  Any advice on how to achieve this would be appreciated.</p>