title: Flash Message Displaying Twice in Rails
body: <p>I'm trying to display a flash when a user visits a page which thanks them for visiting the page which gives them the option to share the url with their friends.  However, the flash message is showing on the page (correct), but then carrying over to the next page that they visit.  How can I make the this only show on the first page?</p>
  
  <p>Right now, the method/view where I want the message show is:</p>
  
  <pre><code>def show    
    user_message
  end
  </code></pre>
  
  <p>user_message is a method in my app controller:</p>
  
  <pre><code>def user_message
    if current_user    
      flash[:page_visited] = "Thank you for visiting!"
    end
  end  
  </code></pre>
  
  <p>I use a partial (that's included in my app layout) for my flash notices:</p>
  
  <pre><code>&lt;% flash.each do |name, msg| %&gt;
    &lt;% if name == :notice %&gt;  
      &lt;div class="alert-message block-message success" data-alert="alert"&gt;
          &lt;a class="close" data-dismiss="alert"&gt;×&lt;/a&gt;
          &lt;%= msg %&gt;&amp;nbsp;&lt;br /&gt;  
      &lt;/div&gt;
    &lt;% elsif name == :page_visited %&gt; 
      &lt;div class="alert-message block_message warning" data-alert="alert"&gt;
          &lt;a class="close" data-dismiss="alert"&gt;×&lt;/a&gt;
          &lt;strong&gt;&lt;%= msg %&gt;&lt;br&gt;&lt;br&gt;&lt;/strong&gt;
          Let your friends and family know!&lt;br /&gt;&lt;br /&gt;
          &lt;!-- ShareThis Button BEGIN --&gt;
          &lt;span class='st_facebook_large'&gt;&lt;/span&gt;
          &lt;span class='st_twitter_large'&gt;&lt;/span&gt;
          &lt;span class='st_plusone_large'&gt;&lt;/span&gt;      
          &lt;span class='st_sharethis_large'&gt;&lt;/span&gt;
          &lt;!-- ShareThis Button END --&gt;
      &lt;/div&gt;  
    &lt;% else %&gt; 
      &lt;div class="alert alert-message error" data-alert="alert"&gt;
          &lt;a class="close" data-dismiss="alert"&gt;×&lt;/a&gt;
          &lt;%= msg %&gt;
      &lt;/div&gt;
    &lt;% end %&gt; 
  &lt;% end %&gt;
  </code></pre>
  
  <p>So what happens is that it will show correctly on the :show view, but on the next page the user clicks to the message shows again and uses the flash "error" format and doesn't show the ShareThis links (although the url would not be the one I would want them to share anyway).</p>
  
  <p>How can I correct this?  I tried moving the user_message to a before_filter i.e. </p>
  
  <p><code>before_filter :user_message, :only =&gt; :show</code> </p>
  
  <p>but that did the same thing - showed the flash message on :show and the subsequent page (as an error message).</p>