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

  • Home
  • SEARCH
  • 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 7504213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:29:59+00:00 2026-05-29T21:29:59+00:00

When users sign up to my application I have a welcome message appear on

  • 0

When users sign up to my application I have a welcome message appear on the home page using Devise’s sign_in_count column.

def home
 if current_user.sign_in_count == 1 
  flash.now[:notice] = "Welcome!"
 end
end

The only problem though is it stays there until they sign out and sign back in. How can I make it show only once and disappear when the page is refreshed or changed? Is there some rails way to do this?

Thank you.

EDIT

application.html.erb

<body>
 <div class="container">
   <%= render "shared/flash_message" %>
    <%= yield %>
 </div>
</body>

_flash_message.html.erb

<% [:notice, :error, :alert].each do |level| %>
 <% unless flash[level].blank? %>
  <div class="span12">
   <div class="<%= flash_class(level) %> fade in">
    <a href="#" data-dismiss="alert" class="close">×</a>
     <%= content_tag :p, flash[level] %>
   </div>
  </div>
 <% end %>
<% end %>
  • 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-05-29T21:30:01+00:00Added an answer on May 29, 2026 at 9:30 pm

    In your layouts/application.html.erb you should have something like this:

    <% flash.each do |key,  value| %>
    <%= content_tag(:div, value, class: "flash #{key}") %>
    <% end %>
    

    Doing this way, should works as you expect.

    EDIT

    What if you verify for the current_user is already set?

    def home
     if current_user && current_user.sign_in_count == 1 
      flash.now[:notice] = "Welcome!"
     end
    end
    

    EDIT 2

    OK! Got it! The sign_in_count column from Devise will remain the same until the next login, so, it will always keep showing you the Welcome! message. To make this work as you expect you have to create a flag on it.

    def home
     if current_user && current_user.sign_in_count == 1
      unless session[:display_welcome]
        flash.now[:notice] = "Welcome!"
        session[:display_welcome] = true
      end
     end
    end
    

    You can try using session or cookies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say that you have an application where different kind of users can sign: Firms,
In my application I have two ways of singing up users: Sign up form
I want to create a web application that allows users to sign up, register
In my application, users sign in/sign out via openid ( same as stackoverflow ).
I have 3 application that need single sign on. These are the web config
I have an application that integrates with Facebook using Oauth 2. I can authorize
I have this application where I use Devise and, after login the user is
Let's say I have an ASP.NET web application. I create an aspx page that
I want to build a mobile application that allows end users to sign up
I have a .Net client WPF application using System.DirectoryServices and LDAP for authentication. On

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.