I have a javascript function that takes data from Rails and presents it.
The format it needs:
[
{
title: 'All Day Event',
start: new Date(y, m, 1)
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
}
]
I'm trying to present this data directly from Rails:
<%= raw @bookings.as_json( only: [:title, :start, :end] ).collect{|o| o["booking"]} %>
This is pretty close, producing:
[{"end"=>nil, "start"=>nil, "title"=>...}, {...}, {...}]
All I have left to do now is change each => into :.
- Am I going about this problem the best way?
- If so, how can I make this final substitution in hash format?