Ask A Question

Notifications

You’re not receiving notifications from this thread.

Flash alert/notification messages not displaying for the 'Log In' and 'Log Out' views

Alfred Montalvo Jr asked in Rails

The flash alert/notification for the 'Log In' and 'Log Out' views are not displayed on the screen when a user logs in or out of the Rails application.

I am not getting any errrors or warnings in my log file that I can share.

I can confirm that the Bootstrap CSS file contains the styling used for the flash alert messages.

I am using the Ruby, Rails and gem versions below:
Ruby 2.6.5
Rails 5.2.4.2
Bootstrap 4.4.1
Simple-form 5.0.2
Devise 4.7.1

After installing Simple-form I ran code below from the command line:

 rails generate simple_form:install –bootstrap

And after installing Devise I ran the code below from the command line:

  rails generate devise:install
  rails generate devise User
  rails generate devise:views

I have also added the code below to my application.html.erb:

<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>

And using the above code a flash alert/notification is only displayed for errors that are encountered on the ‘Sign up’ form.

I tried searching for a solution on the internet and I found a partial solution below that will display the flash message without the correct CSS styling for the 'Log In' and 'Log Out' views . The code below was added to my application.html.erb:

<% flash.each do |name, msg| %> 
    <div class='container-fluid' style='padding-right: 35px; padding-left: 35px'>
    <br/>
            <%= content_tag :div, msg, :id => "flash_#{name}",  :class => "alert alert-#{name}" %> 
     </div>
<% end %> 

Can anyone help me resolve the problem that I am running into with the Flash alert/notification messages not displaying with the correct styling for the 'Log In' and 'Log Out' views?

Reply

I found the solution to the problem I was running into for the Flash alert/notification messages not displaying with the correct styling for the 'Log In' and 'Log Out' views. The issue was resolved after I added the alert helper rb file described in the link below.

[https://stackoverflow.com/questions/36747109/to-handle-flash-messages-types-dynamically]

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,651+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.