I am having some trouble iterating through my JSON array. I want to set a certain Schedule based on what the client sends to the server.
The JSON from the client will be sent in this format:
{
"Schedule":
{
"monday": [
12,
15
]
,
"tuesday": [
10,
16
]
}
}
I would like to iterate like this:
params[:Schedule].each do |day| do
day.each do |time|
schedule.add_recurrence_rule(IceCube::Rule.weekly.day(0).hour_of_day(time))
end
end
However this doesn't work, since when I print params[:Schedule].each it prints out monday, 12, 15, tuesday, 10, 16 etc....
Does anyone have a solution for this?