title: Rendering partial template after redirect to another url
body: <p>My goal is to display a welcome message for the user after they create a new account and are redirected to their profile page; i.e., have the message be displayed on their profile page.</p>
  
  <p>With the following code, I'm able to display the message but only for a split second - before the redirect occurs, which is nevertheless successful.</p>
  
  <p>In my controller, I create the message and use an Ajax call to render my JavaScript template:</p>
  
  <pre><code>def create_user
      # ...
      @welcome_msg = "WELCOME"
      format.js { render template: "layouts/message.js.erb" }
      # ...
  end
  </code></pre>
  
  <p><strong>message.js.erb</strong></p>
  
  <pre><code>$(window.location.replace("&lt;%= profile_url %&gt;"));
  $("#welcome_message_placeholder").html("&lt;%= j render partial: 'layouts/welcome_message', locals: { :user =&gt; @user, :welcome_msg =&gt;  @welcome_msg } %&gt;");
  </code></pre>
  
  <p><strong>_welcome_message.html.erb</strong></p>
  
  <pre><code>&lt;%= @welcome_msg %&gt;
  </code></pre>
  
  <p><strong>application.html.erb</strong></p>
  
  <pre><code>&lt;div id="welcome_message_placeholder"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>What do I need to add/change to ensure that the user sees the message only <em>after</em> being redirected?</p>