How to add username field to devise gem?

前端 未结 5 1310
时光说笑
时光说笑 2020-12-14 23:40

Here is what I tried,

  1. rails g migration add_username_to_hrs

  2. bundle exec rake db:migrate

  3. added the

5条回答
  •  情书的邮戳
    2020-12-15 00:38

    If you are using rails 4 then put below code in application controller

    class ApplicationController < ActionController::Base
     before_action :configure_permitted_parameters, if: :devise_controller?
    
     protected
    
     def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) << :username
     end
    end
    

提交回复
热议问题