GithubHelp home page GithubHelp logo

gym-challenge's Introduction

Rails Practice Challenge - Gym

Setup

To download the dependencies for backend, run:

$ bundle install

There is some starter code in the db/seeds.rb file so that once you've generated the models, you'll be able to create data to test your application. You can run your Rails API on localhost:3000 by running:

$ rails s

There are no tests for this application, so you'll need to check your progress by running the server and using Postman to make requests.

Introduction

We're going to build an app for a Gym create the following database structure. You will have three models (and their corresponding tables), Gym, Client and Membership, with the following relationships:

  • A client has many gyms and has many memberships
  • A gym has many clients and has many memberships
  • A membership belongs to a gym and belongs to a client

Migrations

Write migrations to create the following tables:

Gyms Table:

id name address
1 L.A.Fitness Suite 981 1795 Leida Fords, Nataliemouth, TN 14377-4979
2 Planet Fitness 7768 David Avenue, Greenside, PA 67475-3655

Clients Table:

id name age
1 Casie Effertz 18
2 Dorris Bogan 52
3 Bernie Schiller 44
4 Manie Dare 29

Memberships Table:

id gym_id client_id charge
1 1 1 40
2 1 2 40
3 2 1 50
4 2 3 60

Deliverables

It may be helpful to write a list of the routes you'll need before you begin.

A user should be able to:

  • Create a new membership

    • New membership require a gym_id, client_id, and membership charge.
    • Validation: A client can have only one membership with gym
  • View one specific gym

    • if Gym exists, return JSON data for the gym
    • else return error with a status code
  • Delete a gym

    • If the Gym exists, it should be removed from the database, along with any Memberships that are associated with it (a Membership belongs to a Gym, so you need to delete the Memberships before the Gym can be deleted).

      After deleting the Gym, return an empty response body, along with the appropriate HTTP status code.

      If the Gym does not exist, return the following JSON data, along with the appropriate HTTP status code:

      {
        "error": "Gym not found"
      }
  • View one specific client

    • if Client exists, return JSON data for the Client
    • else return error with a status code

Bonus

  • On client show route, send response that includes total amount for all membership for that client.
  • Create index and update routes for gym and client

gym-challenge's People

Contributors

ihollander avatar kurucaner avatar lizbur10 avatar vidhisharma3193 avatar

Watchers

 avatar

Forkers

evatu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.