我想在同一个RABL文件中呈现不同的对象。我该如何渲染这种JSON?
以下是控制器:
def index
@participations = User.find_by(id_number: params[:tc]).participations
@examinations = Examination.all
end
我想要这个JSON输出=>
participations: (will loop participations)
{
name: (participation.examination.name)
shortname: (participation.examination.short_name)
first_name: (participation.user.first_name)
}
examinations: (will loop @examinations)
{
name: (Examination.name)
shortname: (Examination.short_name)
first_name: (User.find_by(id_number: params[:tc]).first_name)
}
感谢。