I have a method call:
def group
    render :json => Group.find(params[:id])
end
Which renders:
{
  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 like to also append a custom attribute the the group model being rendered. For example I'd like the group JSON to include an attribute message : "Hello World"
How can I do this?
Adding a method to my model called message that returns a string and then calling, 
render :json => Group.find(params[:id]), :methods => :message 
did the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With