Skip to content

marlitas/rails_engine

Repository files navigation


Rails Engine

RESTful API for a fictitious e-commerce site that provides business analytics for frontend consumption.

contributors_badge forks_badge stars_badge issues_badge

About The ProjectTools UsedSet UpInstallationHow To UseDatabase SchemaContributingAcknowledgements

About The Project

Rails Engine was built to practice RESTful API development for a front end consumption. The API uses Active Record and SQL to create business analytics and expose select data and information for a front end team.

Learning Goals

  • Building and testing a RESTful API
  • Active Record/SQL queries
  • Serializing data to follow proper JSON contracts
  • CRUD functionality

Tools Used

Development Testing Gems
Ruby 2.7.2 RSpec Pry
Rails 5.2.5 SimpleCov ShouldaMatchers
JSON FactoryBot Faraday
Atom Faker FastJSON
Git/Github
Heroku

Set Up

  1. To clone and run this application, you'll need Ruby 2.7.2 and Rails 2.5.3. Using rbenv you can install Ruby 2.7.2 (if you don't have it already) with:
rbenv install 2.7.2
  1. With rbenv you can set up your Ruby version for a directory and all subdirectories within it. Change into a directory that will eventually contain this repo and then run:
rbenv local 2.7.2

You can check that your Ruby version is correct with ruby -v

  1. Once you have verified your Ruby version is 2.7.2, check if you have Rails. From the command line:
rails -v
  1. If you get a message saying rails is not installed or you do not have version 5.2.5, run
gem install rails --version 5.2.5
  1. You may need to quit and restart your terminal session to see these changes show up

Installation

  1. Fork this repo
  2. Clone your new repo
    git clone https://github.com/#{your_github_username}/rails_engine.git
  3. Install gems
    bundle install
  4. Setup the database
    rails db:create
    rails db:migrate

How To Use

Rails Engine can be used to access fictitious e-commerce data and calculations.

Endpoint Documentation

Request: GET /api/v1/merchants?per_page=50&page=2

Response:

{
  "data": [
    {
      "id": "1",
        "type": "merchant",
        "attributes": {
          "name": "Store 1",
        }
    },
    {
      "id": "2",
      "type": "merchant",
      "attributes": {
        "name": "Store 2",
      }
    },
    {
      "id": "3",
      "type": "merchant",
      "attributes": {
        "name": "Store 3",
      }
    }
  ]
}

Request: GET /api/v1/<resource>/:id

Response:

{
  "data": {
    "id": "1",
    "type": "item",
    "attributes": {
      "name": "Bouncy Ball",
      "description": "A really bouncy ball",
      "unit_price": 109.99
    }
  }
}

Request: POST /api/v1/items

{
 "name": "value1",
 "description": "value2",
 "unit_price": 100.99,
 "merchant_id": 14
}

Response:

{
  "data": {
    "id": "16",
    "type": "item",
    "attributes": {
      "name": "Widget",
      "description": "High quality widget",
      "unit_price": 100.99,
      "merchant_id": 14
    }
  }
}

Contributing

👤 Marla Schulz

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages