Learn Ruby on Rails: Learn Ruby on Rails Series Part 9

After successfully creating validations, relationships, and using scopes in Rails in the previous article, we will next create authentication functionality using Devise.

Daftar Isi

Design? For what ?

Devise is a Rails gem that makes it easy to handle authentication issues. Currency has the following advantages.

  • Rack-based
  • Complete with model, view and controller
  • Allows an application to have multiple authentication models
  • Made with modularity, making this gem easy to use using only the necessary features/modules.

Precious stones? What is a gem? In Rails there is a configuration file used to list the gems used. This gem is like a library usually found on RubyGems.

How to add design gems to rails

To install this device, you can open it Save files in the application file. For example, I will use devices for applications homework_management.

Place the Gemfile on the project

Add the following script to the Gemfile.

gem 'devise'

and on the terminal move to the project folder in use and run the following command.

bundle install

Definition of the Gem system on the project

Run the following command in terminal

rails generate devise:install

This command will generate a configuration file in the folder config/initializers/devise.rb.

Device Configuration

Make sure the configuration for default URL options in the environment files has been created. To set default URL options, open the environment file in the folder config/environments/development.rb.

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
end

before keywords END.

Then open the file application.html.erb which is in the file application/views/layouts/ and add the following line.
just above

<%= yield %>

Configuring the user model

Next we will create a user model, in which this model works to store user data. To create this user model, it will be integrated into the device. The way to do this is to run the following command in the terminal.

rails g devise user

By running this command it will produce a file user migration And user model.



After that, don’t forget to run the command

rake db:migrate

to process the migration file that was created.

After generating the device then on the file config/routes.rb will experience changes. These changes are as follows.
Try running the following command in terminal and see what URLs are generated fromgenerate design

rails routes

Create a user for the first time

The next step we will change the view to show the login and registration links when we first open the page. http://localhost:3000/.
To create a user, if the command was executed correctly then to save the user just open the URL http://localhost:3000/users/sign_up. This page is the user creation/registration page.
User Registration Page


View edit

The next step we will change the view to show the login form when the page is first opened http://localhost:3000/.

The first thing we will do is create a navigation that will appear on each page. This navigation aims to find information about the user log in and links for disconnection. This navigation will be created partially. Remember that partial file names must begin with the sign “_” (emphasize).

Then, at the top of the view type that requires a connection, we add the following script. For example, on the add homework data page.

Editing the controller

Next, we need to make changes to the controller. All you have to do is add the following script to application_controller.rb which is in the file application/controllers.

Now try running the project again by running the following command in the terminal. so do it restart terminal server

The steps above are one way to use Gem devices in Rails projects. This “CURRENCY” gem is very useful for handling authentication in Rails with all the convenience it offers.

That’s all for this lesson on using “CURRENCY”. We hope this tutorial will be an easy-to-understand lesson for all of us.

PakarPBN

A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.

In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.

The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.

Jasa Backlink

Download Anime Batch