rails devise

‘Devise’ is Authentication for Rails App

put on your gemfile

gem 'devise'

don’t forget running bundle install put on your terminal

rails g devise:install

The next step to get Devise going is to run this command

rails g devise User

and then

rake db:migrate

If we run rake routes we can see the routes that this line of code creates.

rake routes

This generator generates a model for your user and adds the following line to your
config/routes.rb file

devise_for :users

devise_scope :user do
  get "signin", :to => "devise/sessions#new"
  get "signup", :to => "devise/registrations#new"
  get "signout", :to => "devise/sessions#destroy"

Drop DB on Heroku

heroku pg:reset DATABASE

to recreate DB

heroku run rake db:migrate
heroku run rake db:seed


heroku run rails console

become a admin?

$ rails console
>> user = User.first
>> user.admin?
=> false
>> user.password = "foobar"
>> user.toggle!(:admin)
=> true
>> user.admin?
=> true