We are proceeding with the rails tutorial.
here page
8.1.4 Display flash message
I did the above item, but two flash messages appear as shown below.

I'm going to do the contents as described in the tutorial, but is something wrong?
If there is something that can be thought of, it would be helpful if you could tell me.

Contents that are likely to be relevant in the various descriptions that have been set are listed below.

The view file (view/sessions/new.html.erb) is as follows.

<% provide (: title, "Log in")%>
<h1>Log in</h1>
    <% = form_for (: session, url: login_path) do | f |%>
      <% = f.label: email%>
      <% = f.email_field: email, class: 'form-control'%>
      <% = f.label: password%>
      <% = f.password_field: password, class: 'form-control'%>
      <% = f.submit "Log in", class: "btn btn-primary"%>
    <% end%>
    <p>New user?<% = link_to "Sign up now!", signup_path%></p>

The session controllers (controllers/sessions_controller) are as follows.

class SessionsController<ApplicationController
  def new
  def create
    user = User.find_by (email: params [: session] [: email] .downcase)
    if user&&user.authenticate (params [: session] [: password])
      # Redirect to user info page after user login
     flash.now [: danger] = 'Invalid email/password combination'
      render 'new'
  def destroy

The route (config/routes.rb) is as follows.

Rails.application.routes.draw do
  get 'sessions/new'
  get 'users/new'
  root 'static_pages # home'
  get '/ help', to: 'static_pages # help'
  get '/ about', to: 'static_pages # about'
  get '/ contact', to: 'static_pages # contact'
  get '/ signup', to: 'users # new'
  post '/ signup', to: 'users # create'
  get '/ login', to: 'sessions # new'
  post '/ login', to: 'sessions # create'
  delete '/ logout', to: 'sessions # destroy'
  resources: users

Please let me know if you have any other necessary information.

  • Answer # 1

    There were two lines in the application.html that spit out the flash.
    (The contents of the exercises were left behind.)