Git Product home page Git Product logo

phase-4-active-model-serializer-lab's Introduction

Active Model Serializer Lab

Learning Goals

  • Use Active Model Serializer to render JSON
  • Use Active Model Serializer to render JSON for associations

Introduction

For this lab, we're going to return to our Blog application and update it to use ActiveModel::Serializer for JSON serialization.

To set up the app, run:

$ bundle install
$ rails db:migrate db:seed
$ rails s

Our app includes four resources: Author, Profile, Post, and Tag, as well as a post_tag join table. All the associations have been set up, as well as index and show routes and actions for each of the four resources.

Start by building the serializers based on the instructions below. Check your work in the browser as you go. Then, run learn test to make sure your code passes the tests.

Instructions

Author

Set up a serializer for Author that returns the following JSON:

  1. The author's name
  2. The author's profile, including only the username, email, bio and avatar_url
  3. A list of the author's posts, including:
  • the title
  • the first 40 characters of the post's content as short_content, with a trailing ellipsis (...) at the end
  • a list of the associated tags

Note: You will need to make serializers for the Profile and Post models to get this working.

Posts

Set up a serializer for the Post model that displays the following:

  1. The post's title and content
  2. The name of the author
  3. The tags associated with the post

Tags

Set up a serializer for Tag that displays the following:

  1. The name of the tag
  2. A list of the posts the tag is associated with

phase-4-active-model-serializer-lab's People

Contributors

ihollander avatar lizbur10 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phase-4-active-model-serializer-lab's Issues

author_posts_serializer.rb file is not needed in the solution branch. author_post_serializer.rb just needs the "belongs_to :author" relationship.

Canvas Link

https://github.com/seenso/phase-4-active-model-serializer-lab/tree/solution/app/serializers

Concern

author_posts_serializer.rb file is not needed in the solution branch. author_post_serializer.rb just needs the "belongs_to :author" relationship.

Additional Context

rspec/learn test tests passed when I made the suggested change.

Suggested Changes

delete the "author_posts_serializer.rb file." Add "belongs_to :author" to "author_post_serializer.rb" file.

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.