11. Introduction to Ruby on Rails I
Activity 11.01: Adding Authentication for the Review Application
Solution:
- Add the following gem in your gemfile:
gem 'devise'
- Open a Terminal, go to the root of the application folder, and install the gem using the following command:
$ bundle install
- After the gem is installed, type the following command into your Terminal:
$ rails generate devise:install
The output should be as follows:
Figure 11.32: Setting up initial files for the devise gem
This generator sets up all initial files required for devise. There are also some instructions related to customization, which is outside the scope of this activity.
- Generate a
User
model to manage user authentication. Type the following command in a Terminal:$ rails generate devise User
The output is as follows:
Running via Spring preloader in process 15790 invoke active_record create ...