diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 09705d1..ea09ce8 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,2 +1,9 @@
class ApplicationController < ActionController::Base
+ before_action :configure_permitted_parameters, if: :devise_controller?
+
+ protected
+
+ def configure_permitted_parameters
+ devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
+ end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 933dcf8..1883672 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -2,7 +2,9 @@ class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :validatable
+ :recoverable, :rememberable, :validatable, :confirmable
has_many :recipes
+
+ validates :name, presence: true
end
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
index d655b66..16d9feb 100644
--- a/app/views/devise/registrations/new.html.erb
+++ b/app/views/devise/registrations/new.html.erb
@@ -3,6 +3,11 @@
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
+
+ <%= f.label :name %>
+ <%= f.text_field :name, autocomplete: "name" %>
+
+
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 7fe45ba..e84c887 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -14,7 +14,7 @@
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
- # config.secret_key = 'b0a624c7987f9f7b948328d3628cc18f1dfa0ecaf19670d4afac00f34a25d3f95f6902602e8c6a36825f262b0c24c4d59646a66db5bf4d8dcc629fd9c664ca43'
+ # config.secret_key = 'd21917bf1c93328cf178ee11655b51988e59f91faf1c5197272af90c443ed840f18c693c21f9a5f9d325918316d739e3af8f22e9e4b5afbfd5f2664e6dd4b963'
# ==> Controller configuration
# Configure the parent class to the devise controllers.
@@ -126,7 +126,7 @@
config.stretches = Rails.env.test? ? 1 : 12
# Set up a pepper to generate the hashed password.
- # config.pepper = '3744a9e96514b19a468c01ac76c9971acd68813f3b648f6c18c1029a644caa3434b32eca2cf7c10603600fed3e6eada53c962eb2e79fbf716d48bb1a0881de1a'
+ # config.pepper = '9e248af07ed8b30a8f7b4e864c9731ca922cbcce0465a6c76b09d29ee8bb4cb2a4fbf456d0a7109393f232577651aeac91a008576bf1738821f92f515b174db9'
# Send a notification to the original email when the user's email is changed.
# config.send_email_changed_notification = false
diff --git a/db/migrate/20231219114224_add_confirmable_to_users.rb b/db/migrate/20231219114224_add_confirmable_to_users.rb
new file mode 100644
index 0000000..0024cd6
--- /dev/null
+++ b/db/migrate/20231219114224_add_confirmable_to_users.rb
@@ -0,0 +1,8 @@
+class AddConfirmableToUsers < ActiveRecord::Migration[7.1]
+ def change
+ 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
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f1ed664..9f58873 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2023_12_18_224428) do
+ActiveRecord::Schema[7.1].define(version: 2023_12_19_114224) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -56,6 +56,10 @@
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.string "confirmation_token"
+ t.datetime "confirmed_at"
+ t.datetime "confirmation_sent_at"
+ t.string "unconfirmed_email"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end