Giter Site home page Giter Site logo

using-active-model-serializer-lab-dc-web-091718's Introduction

Using ActiveModel::Serializer Lab

Objectives

  1. Use AMS to render JSON.
  2. Use AMS to render JSON associations.

Introduction

We're going to continue updating our products/orders system to use ActiveModel::Serializer for JSON serialization. The solution to the previous lab is provided.

Don't forget to run rake db:seed for some starter data and lots of Latin practice!

Instructions

  1. Create an ActiveModel::Serializer for Product and update the products_controller to use the new serializer in place of the existing to_json code.
  2. Update the product show page to handle the new JSON.
  3. On the products index page, update the More Info button so that it uses the /products/id.json route to get both description and inventory.
  • Note: The serializer will return a different value for inventory than the previous API, so you'll have to handle that.
  1. Update the ProductSerializer to include the orders for the product.
  2. Update the More Info button on the products index page to show a list of orders with id and created_at in addition to the description and inventory.
  3. Update the OrderSerializer to include the product names of all products on that order.
  4. Get rid of the unused /products/id/description and /products/id/inventory routes.
  5. Make sure tests pass!

using-active-model-serializer-lab-dc-web-091718's People

Contributors

mendelb avatar aviflombaum avatar scottcreynolds avatar maxwellbenton avatar pletcher avatar cernanb avatar jilustrisimo avatar

Watchers

 avatar Kevin McAlear avatar  avatar Victoria Thevenot avatar Belinda Black avatar  avatar Joe Cardarelli avatar Sam Birk avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Jaichitra (JC) Balakrishnan avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar A. Perez avatar Nicole Kroese  avatar  avatar Lore Dirick avatar Nicolas Marcora avatar Lisa Jiang 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.