1

I have a signup form for devise-token-auth. I would like users to enter a username as well on the signup form. The username column exists in the database but the controller rejects it

Unpermitted parameter: :username

How can I extend the permitted parameters for signup in devise token auth?

Qwertie
  • 5,784
  • 12
  • 45
  • 89

2 Answers2

1

Looks like this works exactly the same as regular devise. The general idea can be found from this page

But specifically, add this to ApplicationController

before_action :configure_permitted_parameters, if: :devise_controller?

protected

def configure_permitted_parameters
  added_attrs = [:username, :email, :password, :password_confirmation]
  devise_parameter_sanitizer.permit :sign_up, keys: added_attrs
  devise_parameter_sanitizer.permit :account_update, keys: added_attrs
end
Qwertie
  • 5,784
  • 12
  • 45
  • 89
0

You need to set permitted params in your controller's action. Look this https://api.rubyonrails.org/classes/ActionController/Parameters.html

IlyaOsotov
  • 126
  • 6