Adding name attribute to `User` in Devise

后端 未结 8 1711
轻奢々
轻奢々 2020-12-31 00:31

I\'m trying to add a name attribute to the User model provided by Devise. I added a \"name\" column to my database, and changed the sign up view so that it asks for the use

8条回答
  •  被撕碎了的回忆
    2020-12-31 00:58

    For Rails 4

    Use like this

    protected
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me) }
      devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
      devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
    end
    

    Add additional fields at the end.

提交回复
热议问题