Create a Car model class as per the class diagram below.
Seed the database with Car objects.
Retrieve and print all saved Car objects using the Rails console.
Steps
Create Car model class:
Add a new Car model class to the app that follows the above design.
📸 Screenshot: The terminal showing the rails generate command and its output.
Seed database:
Use the seeds.rb script to add the following seed data to the app:
Ford, F-150 Lightning, 2023, Silver
Toyota, Prius Prime, 2023, Blue
Chevrolet, Corvette, 2022, Blue
Toyota, Camry, 2021, Red
📸 Screenshot: The VS Code editor showing the completed seeds.rb file.
Retrieve and print cars (unsorted):
In the Rails console, retrieve all four model objects (no order specified), and print the year, color, and make of each.
📸 Screenshot: The Rails console showing the Ruby code you entered and its output.
💡 Hint: When printing, you may need to convert the integer attribute year to a string with the to_s method (e.g., my_car.year.to_s).
Retrieve and print cars (sorted):
In the Rails console, retrieve all four model objects sorted in ascending order first by make and second by year, and print the year, color, and make of each.
📸 Screenshot: The Rails console showing the Ruby code you entered and its output.
How to Submit
Submit Word DOCX file containing your screenshots to the designated Canvas assignment.
Solution Demonstration
⚠ Important! Attempt challenge task on your own before watching.