Authentication with Devise Copy

Adds user authentication to your app using the Devise gem
Icons/chart bar
Used 10 times
Created by
MalTheGreat MalTheGreat

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/zPdsB3"
Template Source

Review the code before running this template on your machine.

def do_bundle
  # Custom bundle command ensures dependencies are correctly installed
  Bundler.with_unbundled_env { run "bundle install" }
end

run "bundle add devise"
do_bundle

rails_command "generate devise:install"

model_name = ask("What do you want to call your Devise model?")
attributes = ""
if yes?("Do you want to any extra attributes to #{model_name}? [y/n]")
  attributes = ask("What attributes?")
end

# We don't use rails_command here to avoid accidentally having RAILS_ENV=development as an attribute
run "rails generate devise #{model_name} #{attributes}"
Comments

Sign up or Login to leave a comment.