Rails render json add custom attribute
I have a method call:
def group
render :json => Group.find(params[:id])
end
What is he doing:
{
id: 1,
name: "Name Here",
description: "Description Here",
created_at: "2014-11-24T19:10:53.609Z",
updated_at: "2014-11-24T19:10:53.609Z"
}
I would also like to add a custom attribute that renders the group model. For example, I would like the JSON group to include the attributemessage : "Hello World"
How can i do this?
+3
source to share