【发布时间】:2014-12-08 19:49:40
【问题描述】:
我有一个方法调用:
def group
render :json => Group.find(params[:id])
end
呈现:
{
id: 1,
name: "Name Here",
description: "Description Here",
created_at: "2014-11-24T19:10:53.609Z",
updated_at: "2014-11-24T19:10:53.609Z"
}
我还想为正在呈现的组模型附加一个自定义属性。例如,我希望 JSON 组包含属性 message : "Hello World"
我该怎么做?
【问题讨论】:
标签: ruby-on-rails json ruby-on-rails-4