I'm new to rails and I'm trying to create an API for my application. I'm also using rabl for generating my JSON responses. In my rabl template I want to send a timestamp and a collection of items.
The code looks like this:
object false
node(:timestamp){CourseType.maximum("updated_at")}
child(@course_types){attributes :id, :name, :deleted}
And I want to get an object that would look like this:
{"course_types":
[{"id":2,"name":"Driving","deleted":false},
{"id":4,"name":"Cooking","deleted":false}],
"timestamp":"2016-04-25 16:22:57 UTC"}
However I'm getting this instead:
{"course_types":
[{"course_type":
{"id":2,"name":"Driving","deleted":false}},
{"course_type":
{"id":4,"name":"Cooking","deleted":false}}],
"timestamp":"2016-04-25 16:22:57 UTC"}
Any ideas on how to solve this?
Thanks