A question about if adding the :current_password attribute in the RegistrationController is the right way to go?
User model with include ActiveModel::ForbiddenAttributesProtection
# app/model/user.rb
class User < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
Passwords controller that inherits from Devise's passwords controller
# app/controllers/users/passwords_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
Registration controller that inherits from Devise's registration controller
# app/controllers/users/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController
def resource_params
params.require(:user).permit(:name, :email, :password, :password_confirmation, :current_password)
end
private :resource_params
end
Route for Devise to use specified users' passwords and registrations controller.
# config/routes.rb
devise_for :users, :controllers => {:registrations => "users/registrations", :passwords => "users/passwords"}
In the RegistrationsController
I had to add the attribute :current_password
for users to be able to edit their profile.
The reason I ask is without strong_parameters
I would only specify an attr_accessible
for :email, :password, :password_confirmation, :remember_me
.
Any insights is much appreciated.