Current password can't be blank and an error message. .. ..
rails generate devise:controllers users
create app/controllers/users/confirmations_controller.rb
create app/controllers/users/passwords_controller.rb
create app/controllers/users/registrations_controller.rb
create app/controllers/users/sessions_controller.rb
create app/controllers/users/unlocks_controller.rb
create app/controllers/users/omniauth_callbacks_controller.rb
#registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
protected
def update_resource(resource, params)
resource.update_without_password(params)
end
end
devise_for :users, controllers: { registrations: 'users/registrations' }
#views/devise/registrations/edit.html.Removed from erb
(The value specified in the User model is handled as an instance variable)
#abridgement
attr_accessor :current_password
with_options format: { with: /\A(?=.*?[a-z])(?=.*?\d)[a-z\d]{6,}+\z/i } do
validates :password, presence: true, on: :create
validates :password_confirmation, presence: true, on: :create
end
#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
private
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [#abridgement])
devise_parameter_sanitizer.permit(:account_update, keys: [#abridgement])
end
end
Recommended Posts