How to create admin at start up application using Devise gem

1. Run
$ rails new app
$ cd app

2. Add to Gemfile:

 gem 'devise'

run
 $ bundle install
$ rails g controller admin home

$ rails generate devise:install
$ rails generate devise Admin
$ rake db:migrate

4. Add to db/seeds.rb:
Admin.create(email: 'brian.vanloo@gmail.com', password: 'insecure-password')
 
Then run:
$ rake db:seed
 
 
5. Add to any controller to be authenticated:
before_action :authenticate_admin! 



Comments