Code Monkey home page Code Monkey logo

butcher-shop's Introduction

Butcher Shop Sample App

This is a sample API app for a butcher shop. It's broken and incomplete. Your job is to fix it and finish it.

Tasks

What we'd like you to do is the following:

Fix the Tests

This app has a bunch of tests. Some of them are failing, and some of them are broken. You must get all tests to pass

Add a Model & Resources

There is a user model, but it's currently pointless. Let's make it have meaning in life by adding a new model that belongs to users called Favorite. Users can have many favorites and a favorite has a cut of meat. In addition to creating the model, you must create a set of resources for favorites that allows you to view all of a user's favorites, and create, update, and destroy. These resources would have the following routes:

  • GET /users/:id/favorites
  • POST /users/:id/favorites
  • GET /favorites/:id
  • PUT /favorites/:id
  • DELETE /favorites/:id

No other routes should be added to the app, and all these requests can be handled by one controller. Make sure you add tests for your controller and model where appropriate.

Finally, the response for GET /users/:id/favorites should include the cut of meat, not just the cut_id. For example:

{
  favorites: [
    {
      ... favorite attributes
      cut: {
        name: "whatever"
        ... cut attrs
      }
    }
  ]
}

HINT: You can pull this nesting off with one line in a serializer

Create DB Seeds

Finally, we'd like to add some database seeds to the seeds.rb file. Please make the seeds create the following:

  • Animals:
    • Cow
      • Primal Cuts:
        • Chuck
        • Short Loin
        • Rib
          • Cuts:
            • Prime Rib
            • Ribeye
      • Cuts:
        • Porterhouse
        • T-bone
        • Strip
    • Pig
      • Primal Cuts:
        • Jowl
        • Ham
        • Loin
          • Cuts:
            • Loin Chop
            • Blade Roast
      • Cuts:
        • Babyback Rips
        • Spareribs
        • Hock

The items in bold represent the models, and the items under represent the entries to create.

Notes

Please note that this app uses the rails-api gem, and is not a traditional rails app. Nothing that is broken in this app is a trick, you should be able to fix everything with a basic knowledge of rails and by reading the errors.

Submitting Your Response

Simply fork this repo on github, then submit a pull request when you've completed the tasks.

butcher-shop's People

Contributors

erinzobitz avatar

Watchers

James Cloos avatar  avatar

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.