change json contract

This commit is contained in:
João Victor Geonizeli
2022-02-28 12:40:17 -03:00
parent bf3253dc9e
commit aa0e1ac1c7
4 changed files with 14 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
json.extract! post, :id, :content, :created_at, :updated_at json.extract! post, :id, :content, :created_at
json.quoted_post(post.quoted_post, partial: 'posts/post', as: :post) if post.quoted_post json.quoted_post(post.quoted_post, partial: 'posts/quoted_post', as: :post) if post.quoted_post
json.user(post.user, partial: 'users/user', as: :user) if post.user json.user(post.user, partial: 'posts/user', as: :user)
json.url post_url(post, format: :json) json.url post_url(post, format: :json)

View File

@@ -0,0 +1,2 @@
json.extract! post, :id, :content, :created_at
json.user(post.user, partial: 'posts/user', as: :user)

View File

@@ -0,0 +1,3 @@
json.extract! user, :id, :username
json.url user_url(user, format: :json)

View File

@@ -1,2 +1,7 @@
json.extract! user, :id, :username, :created_at, :updated_at json.extract! user, :id, :username
json.joined_at user.created_at.strftime("%B %d, %Y")
json.following_count user.following.count
json.follower_count user.followers.count
json.posts_count user.posts.count
json.url user_url(user, format: :json) json.url user_url(user, format: :json)