Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7822347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:54:20+00:00 2026-06-02T07:54:20+00:00

I’m trying to display a flash when a user visits a page which thanks

  • 0

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?

Right now, the method/view where I want the message show is:

def show    
  user_message
end

user_message is a method in my app controller:

def user_message
  if current_user    
    flash[:page_visited] = "Thank you for visiting!"
  end
end  

I use a partial (that’s included in my app layout) for my flash notices:

<% flash.each do |name, msg| %>
  <% if name == :notice %>  
    <div class="alert-message block-message success" data-alert="alert">
        <a class="close" data-dismiss="alert">×</a>
        <%= msg %>&nbsp;<br />  
    </div>
  <% elsif name == :page_visited %> 
    <div class="alert-message block_message warning" data-alert="alert">
        <a class="close" data-dismiss="alert">×</a>
        <strong><%= msg %><br><br></strong>
        Let your friends and family know!<br /><br />
        <!-- ShareThis Button BEGIN -->
        <span class='st_facebook_large'></span>
        <span class='st_twitter_large'></span>
        <span class='st_plusone_large'></span>      
        <span class='st_sharethis_large'></span>
        <!-- ShareThis Button END -->
    </div>  
  <% else %> 
    <div class="alert alert-message error" data-alert="alert">
        <a class="close" data-dismiss="alert">×</a>
        <%= msg %>
    </div>
  <% end %> 
<% end %>

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).

How can I correct this? I tried moving the user_message to a before_filter i.e.

before_filter :user_message, :only => :show

but that did the same thing – showed the flash message on :show and the subsequent page (as an error message).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:54:21+00:00Added an answer on June 2, 2026 at 7:54 am

    try flash now

    def user_message
      if current_user    
        flash.now[:page_visited] = "Thank you for visiting!"
      end
    end  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.