If you want your json to come out like this:
{"id":1,"attribute1":1,"attribute2":2}
You can do it:
json.array! @my_object
However, if you need an output that looks like this:
{"my_object":{"id":1,"attribute1":1,"attribute2":2}}
You can do it:
json.my_object @my_object
source share