
Newb to rails. Followed instructions:
gem 'devise'bundle installrails g devise:installrails g devise:viewsrails db:migrateclass AddConfirmableToDevise < ActiveRecord::Migration[5.1]
# Note: You can't use change, as User.update_all will fail in the down migration
def up
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string # Only if using reconfirmable
add_index :users, :confirmation_token, unique: true
# User.reset_column_information # Need for some types of updates, but not for update_all.
# To avoid a short time window between running the migration and updating all existing
# users as confirmed, do the following
User.all.update_all confirmed_at: DateTime.now
# All existing user accounts should be able to log in after this.
end
def down
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
remove_columns :users, :unconfirmed_email # Only if using reconfirmable
end
end
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable
end
<!DOCTYPE html>
<html>
<head>
<title>JobApp</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<!-- Added these from rails g devise:install instructions -->
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= yield %>
</body>
</html>
It seems like <p id="notice"> is being injected into the page... which is strange since <p class="notice"> already exists and Devise is notifying to that as well. :\
Am I newb or is this bug?
Can you share your layout and make sure there is no double rendering of flash notice?
application.html.erb<!DOCTYPE html>
<html>
<head>
<title>JobApp</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<!-- Added these from rails g devise:install instructions -->
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= yield %>
</body>
</html>
Hello @corysimmons, thanks for your report.
Your application layout looks correct, but by looking at your print screen it shows two <p> tags with the content of flash notice: one with class="notice" and other with id="notice". Your layout defines only the first one, this means that other partial should be defining the later.
Please use StackOverflow for questions/help in the future, where a wider community will be able to help you. We reserve the issues tracker for issues only. Thank you!
This is an issue (whether it's a bug or documentation problem) since I followed directions verbatim and ended up with duplicate flash messages that I'm unable to easily traceback to the source.
Devise is injecting id="alert" by itself, but I don't know how/why.
@corysimmons we have no code that injects this kind of thing in the template. As you can see here we only set the flash message in the controllers.
Oh you're right! I'm so stupid. rails generate scaffold produced the <p id="notice"><%= notice %></p> X_X
I'm sorry for wasting your time!
@corysimmons No problem, I'm glad you found the solution 馃憤