Skip to content

Instantly share code, notes, and snippets.

@john-hamnavoe
Created December 5, 2022 11:02
Show Gist options
  • Save john-hamnavoe/2eaf18393d55adb1514ccd4458612b5a to your computer and use it in GitHub Desktop.
Save john-hamnavoe/2eaf18393d55adb1514ccd4458612b5a to your computer and use it in GitHub Desktop.

gem "devise"

rails generate devise:install

rails generate devise User

(revise user table definition as required e.g. add Admin column etc.)

rails db:migrate

rails g devise:views

Other Notes

  • If having trouble you might need data: {turbo: false } on links generated in the views
  • If want to hide menu when showing sign in forms etc can use if user_signed_in? in application.html.erb

If you have other fields to capture on registration form (e.g. name) add to Application Controller as shown

class ApplicationController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment