Skip to content

Commit

Permalink
Configure permitted parameters for Devise in ApplicationController
Browse files Browse the repository at this point in the history
•Created a method update_allowed_parameters in ApplicationController to configure permitted parameters for Devise.
•Added a before_action callback to invoke the update_allowed_parameters method before any Devise controller action.
•In the update_allowed_parameters method, used devise_parameter_sanitizer.permit to specify the permitted parameters for sign-up and account update actions.
•For sign-up, permitted the name, email, and password attributes.
•For account update, permitted the name, email, password, and current_password attributes.
  • Loading branch information
Lucas-Erkana committed Jul 10, 2023
1 parent 20ee95f commit 97b67f5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
class ApplicationController < ActionController::Base
end
protect_from_forgery with: :exception

before_action :update_allowed_parameters, if: :devise_controller?

protected

def update_allowed_parameters
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password) }
devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :password, :current_password) }
end
end

0 comments on commit 97b67f5

Please sign in to comment.