This is a simple Ruby on Rails application that helps manage a list of friends. The app includes authentication using Devise and allows you to store and manage personal information such as first name, last name, email, and phone number.
- Ruby 3.3.7
- Rails 8.0.1
Make sure you have the following installed on your system:
- Ruby (version 3.3.7 or higher)
- Rails (version 8.0.1 or higher)
- A supported database (e.g., PostgreSQL, MySQL, SQLite)
Follow the steps below to get the application up and running on your local machine.
Run the following command to install the required dependencies:
bundle install
Create a home
controller with an index
action:
rails g controller home index
This will create a model, controller, and views for managing friends:
rails g scaffold Friend first_name:string last_name:string email:string:uniq phone:string:uniq
Add devise
to your Gemfile:
gem 'devise'
Then install the gem:
bundle install
Run the following command to install Devise:
rails g devise:install
Follow the instructions shown in the terminal, which include:
- Adding Devise configuration to
config/environments/development.rb
- Setting the root path to
home#index
root "home#index"
To customize the views for Devise, run the following command:
rails g devise:views
Run the following command to create the database and apply migrations:
rails db:migrate
Now, generate the Devise user
model:
rails g devise user
Create a migration to add the user_id
column to the friends
table:
rails g migration AddUserIdToFriends user_id:integer:index
Then run the migration:
rails db:migrate
Make sure all gems are installed and up to date by running:
bundle install
bundle update
Finally, start the Rails server:
rails s
You can now visit the application in your browser at http://localhost:3000
.
Now, you have a working Rails application with authentication (via Devise) and basic CRUD functionality for managing friends!