[Ruby] Freeters everywhere tried using devise.

1 minute read

Thanks,

I am a freeter who aims to be an engineer from inexperience.

This time, even beginners can easily

A gem famous for being able to create user management functions from scratch

devise

about,

While sandwiching some explanations,

I would like to introduce you briefly.

First of all, let’s create a rails app

rails _6.0.0_ new (your desired app name) -d mysql

(The last -d is optional, so you don't have to add it if you don't need it.)

After installation, let’s move to the folder you just created

Open a terminal and run the following command

% cd (the app name you created)

For the time being, create a database to store the data.

Open a terminal and run the following command

% rails db:create

Next, add the device gem with Gemfile

gem'devise'

Don’t forget to add it in Gemfile

do a bundle install! !! (Also start with rails s!!)

Then, with the terminal open Type the following command

rail g devise:install

This command will start the device As a personal impression, I feel the most when I hit this command lol

Don’t forget to create the controller.

% Rails g devise:controllers users

This command changes the user-related controller of device It will create at once

Because the migration file of user is generated by this

Don’t forget the process of sending.

rake db:migrate

And this command

rails g devise:views

All device related views at once Will make it! !!

I didn’t know this first,

I wrote everything myself…

You don’t have to have that experience anymore!

It makes me feel at ease.

This concludes the introduction of device-related commands!

It’s so easy for anyone to create a user management function…

gem’s power is scary…

I want to add sns authentication to the user registration function!

Those who say

https://developers.facebook.com/

Access that place

After registering variously,

gem'omniauth-facebook'

If you use the gem

You can now authenticate with Facebook!

(I have other things to do…)

Why don’t you take a look at this opportunity! !!