I am trying to get a custom json in rails app to fetch nested user data and their post respectivelly but page is not displaying right content
问题 I have 3 model user, post and comment. the user can have multiple post and comments. I need to produce the JSON for last 50 post only. I am not using rails convention, so i have to write that in neewsfeed_controller. Thank for the support. class NewsfeedsController < ApplicationController respond_to :json def build @posts = Post.all.order("created_at DESC") render json: {:event => @posts} end def data @posts = Post.all.order("created_at DESC") render :partial => "newsfeeds/data.json" end