Created
May 23, 2021 16:49
-
-
Save UsamaAshraf/1e61cd388ad2b37d451077894982f27f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
def index | |
posts = Post.all | |
render json: posts | |
end | |
end | |
class Post | |
belongs_to :author, class_name: 'User' | |
end | |
class PostSerializer < ActiveModel::Serializer | |
attributes :id, :title, :details | |
belongs_to :author | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment