0

Hello together I try to get two additional variables, which will be generated by the server, to the sign up process of devise.

My registration controller looks like this:

class RegistrationsController < Devise::RegistrationsController

  private

  def sign_up_params
    public_key = 'test123'
    private_key ='private_test123'
    params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :public_key => public_key, :private_key => private_key)
  end

  def account_update_params
    params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password)
  end
end

But devise do not save the variables public and private_key. (The Database is set up correctly and contains the two variables)

Do you know how I can fix that?

Thanks a lot!

1 Answers1

0

The method sign_up_params is only to white list keys which is not default to devise so you just need :

params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :public_key, :private_key)

to white list those 2 varibale. This will not send those two variable to database unless you send those values from the form or add it to from devise create action from RegistrationController.

To get an idea how to override default create action see this

you don't need these

public_key = 'test123'
private_key ='private_test123'

in sign_up_params

Community
  • 1
  • 1
Sajan
  • 1,893
  • 2
  • 19
  • 39