Adding Initial Devise Authentication

|

For the first time in a week I was able to add the initial authentication of the Scrapcal app using the Devise plugin.

Scrapcal doesn’t do anything yet; it is just an empty index page. However, it will be an app to create calendar photos for scrapbooks. Mostly it’s just an app to build and showcase my Rails skills.

It doesn’t seem Devise is yet compatible with Rails 5.1, as it was just released. So I reset Rails to 5.0.

I was able to generate a set of rudimentary redirects using the instructions on the Devise Gem GitHub readme.

I also removed the ability for the public to sign up and recover their password by removing the ‘:registerable, :recoverable’ symbols from the devise line in the User model.

From this autogenerated model:

class User < ApplicationRecord
 # Include default devise modules. Others available are:
 # :confirmable, :lockable, :timeoutable and :omniauthable
 devise :database_authenticatable, :registerable,
 :recoverable, :rememberable, :trackable, :validatable
end

To this Model:

class User < ApplicationRecord
 # Include default devise modules. Others available are:
 # :confirmable, :lockable, :timeoutable and :omniauthable
 devise :database_authenticatable,
 :rememberable, :trackable, :validatable
end

Cannot Logout with GET request

Once authenticated, it doesn’t show anything but the Home#index page

Just the Home page from the root route

Right now I can’t seem to log out, as I believe the link shown above does a GET request and it needs to be DELETE. It is working on my local though, but shows an error when clicked on staging.

No path is found.

Here is the corresponding Rails log error:

No route matches [GET] “/users/sign_out”
Here is the ‘rake routes’ from staging (right) and local (left) to show the are identical.

Stage (grey left) and Local (red right) have identical routes.

Below is a quick changelog of the tasks completed tonight and the next steps.

Tasks Completed Tonight:

  • Add Devise gem
  • Implement initial models and routes
  • Deploy to rudimentary staging
  • Set up new scrapcal.com domain
    • Buy Domain
    • Set up Digital Ocean networking
    • Set up Let’s Encrypt SSL for stage and prod
    • Implement stage on stage.scrapcal.com

Tasks Up Next:

  • Implement Gitlab CI for staging instance
    • precompile assets
  • Create simple readme
  • Add to github (reset secrets?)
  • Add secrets.yml for staging instance
  • Fix /users/sign_out path problem
  • Implement MySQL for staging instance
  • Get better at logging?

Leave a Reply

Your email address will not be published. Required fields are marked *