This project is part of The Odin Project: Kittens API in the Ruby on Rails curriculum.
By the end of this project, you will be able to:
- Create a Rails application that serves both HTML and JSON responses.
- Implement RESTful routes and controller actions for a resource.
- Use Active Record to manage data through models.
- Handle flash messages for user notifications.
- Test API responses using the
rest-client
gem.
HTML Setup:
- Create Rails App: Generate a new Rails application (
odin-kittens
) and initialize a Git repository. - Generate Kitten Model: Create a
Kitten
model with attributes:name
,age
,cuteness
, andsoftness
. - KittensController: Implement a
KittensController
with routes for all 7 RESTful actions. - Root Route: Set
kittens#index
as the root route and build HTML views for all actions. - Flash Messages: Add flash messages for success/error handling and delete links for kittens.
- Testing: Ensure all controller actions are functioning correctly.
JSON API Setup:
- REST Client Requests: Use the
rest-client
gem to make requests to the app. - JSON Responses: Modify
KittensController#index
to respond with JSON and implement a JSON response for theshow
action. - Test API Responses: Validate API responses using the
RestClient
.
- RESTful API: Provides both HTML views and JSON API endpoints for accessing kittens data.
- CRUD Operations: Implement full CRUD functionality for kittens through a web interface.
- Flash Notifications: User-friendly messages to indicate success or failure of actions.
- Ruby on Rails
- ActiveRecord for database management
rest-client
gem for API requests
-
Clone the repository:
git clone https://github.com/jambalong/odin-kittens.git
-
Navigate to the project directory:
cd odin-kittens
-
Install dependencies:
bundle install
-
Set up the database:
rails db:create rails db:migrate
-
Start the Rails server:
rails server
Access the application at http://localhost:3000
.