Git Product home page Git Product logo

phase-4-mini-project-crud's Introduction

Putting it All Together: Rails CRUD

Learning Goals

  • Generate an API that follows REST conventions
  • Handle full CRUD with one model

Introduction

Now's your chance to put all the CRUD actions we've been learning to good use! We're going to be building out an API in Rails as a backend for a spice store. There's a React application in the /client directory that's all set up for the frontend; your goal is to build out the necessary CRUD actions in the backend by following RESTful conventions.

Setup

To set up the frontend and backend dependencies, from the root directory, run:

$ npm install --prefix client
$ bundle install

Instructions

Spice Model

Generate a class and migrations for a Spice model with the following attributes:

  • title (string)
  • image (string)
  • description (string)
  • notes (string)
  • rating (float)

After you've created the model, check your work by running:

$ rails db:migrate db:seed

Then, use rails c to view data about the spices.

Routes

Your API should have the following routes:

  • GET /spices: return an array of all spices
  • POST /spices: create a new spice
  • PATCH /spices/:id: update an existing spice
  • DELETE /spices/:id: delete an existing spice

Make sure to follow REST conventions for generating these routes.

You should also use strong params in the controller for the POST and PATCH requests.

Use the tests to guide your progress and ensure that each route has the expected JSON response body and HTTP status code. You can also run the server with rails s and test out the routes manually using Postman.

Good luck! ๐Ÿ’ช

Once your API is working, you can try out the full application in the browser when you're ready to see everything come together. You can run the Rails application in one terminal by running:

$ rails s

Then, open another terminal and run React:

$ npm start --prefix client

Each application will run on its own port on localhost:

phase-4-mini-project-crud's People

Contributors

ihollander avatar ilyasosman avatar lambert-stephen avatar lizbur10 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.