This repository is a Ruby on Rails application demonstrating the creation of a many-to-many relationship between Player
and Hero
models. Example data is generated using the Faker gem.
- Faker Gem: Used to generate fake data for development and testing purposes.
- Many-to-Many Relationship: Demonstrates the use of a join table to associate
Player
andHero
models.
- Ruby 3.2.2
- Rails 7.2.1
- SQLite3 (for the database)
-
Clone the repository
git clone [email protected]:dalvarez2596/many-to-many.git cd many-to-many
-
Install dependencies
bundle install
-
Setup the database
rails db:create rails db:migrate
-
Seed the database with fake data
The Faker gem is used to generate example data. You can create seed data by running:
rails db:seed
Or you can use:
rails db:setup
-
Start the Rails server
rails server
Or:
rails s
-
Open your browser and navigate to
http://localhost:3000
to view the application. -
Access the Player and Hero management interfaces
-
Players
- List all players:
http://localhost:3000/players
- Create a new player:
http://localhost:3000/players/new
- Edit a player:
http://localhost:3000/players/:id/edit
- Show a player:
http://localhost:3000/players/:id
- Delete a player: Available on the index and show views
- List all players:
-
Heros
- List all heroes:
http://localhost:3000/heros
- Create a new hero:
http://localhost:3000/heros/new
- Edit a hero:
http://localhost:3000/heros/:id/edit
- Show a hero:
http://localhost:3000/heros/:id
- Delete a hero: Available on the index and show views
- List all heroes:
-
Manage Hero Associations
- Add a hero to a player: Available on the player details page
- Remove a hero from a player: Available on the player details page
-
- Ruby: 3.2.2
- Rails: 7.2.1
This project is licensed under the MIT License - see the LICENSE file for details.