Skip to content

Instantly share code, notes, and snippets.

@alvinthen
Last active November 22, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvinthen/1078a4e06f42398ee1aa5105cf5c819d to your computer and use it in GitHub Desktop.
Save alvinthen/1078a4e06f42398ee1aa5105cf5c819d to your computer and use it in GitHub Desktop.
Add fields to devise model

Add name to User model

rails g migration AddNameToUser name:string

Add devise's registrations views to our project

rails g devise:views users -v registrations

Add devise's controllers to our project

rails g devise:controllers users

app/controllers/users/registrations_controller.rb

before_action :configure_sign_up_params, only: [:create]
before_action :configure_account_update_params, only: [:update]

private
  # If you have extra params to permit, append them to the sanitizer.
  def configure_sign_up_params
    devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
  end

  # If you have extra params to permit, append them to the sanitizer.
  def configure_account_update_params
    devise_parameter_sanitizer.permit(:account_update, keys: [:name])
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment