/odin-kittens

Practise building API

Primary LanguageRuby

README

Project 1: Building a simple kittens API

Run this project locally

  1. Clone this repository to your local machine.
git clone git@github.com:helmihidzir/odin-kittens.git
  1. Change into the odin-kittens directory.
cd odin-kittens
  1. Install the project dependencies using bundler.
gem install bundler
bundle install
  1. Create the database.
rails db:create
  1. Run the database migrations.
rails db:migrate
  1. Start the Rails server.
rails s
  1. Lastly, navigate to http://localhost:3000/ to play around with the project.

Test the API

  1. Install rest-client gem and go to the irb:
require 'rest-client'
  1. To GET all kittens:
response = RestClient.get("http://localhost:3000/kittens")
  1. To POST or create new kitten:
response = RestClient.post('http://localhost:3000/kittens', kitten: {name: 'neko', age: 12, cuteness: 5, softness: 5})