rossta / montrose

Recurring events library for Ruby. Enumerable recurrence objects and convenient chainable interface.
https://rossta.net/montrose/
MIT License
842 stars 52 forks source link

Issue when serializing to JSON #129

Closed adambedford closed 3 years ago

adambedford commented 4 years ago

I'm running into an issue when rendering a model with a serialized Recurrence (via serialize :schedule, Montrose::Recurrence)

The error is:

Error: wrong argument type JSON::Ext::Generator::State (expected Fixnum) /Users/adam/.rvm/gems/ruby-2.6.0/gems/json-2.3.0/lib/json/common.rb:222:in `configure'

Has anyone run into this sort of thing before? Actually doing model.to_json in the console works just fine...it's only when rendering the JSON for our API response. I've also tried coercing into an array and using Montrose::Schedule, which also didn't work, so it might be a data issue.

The raw value in the DB for the schedule field is:

"{\"every\":\"week\",\"until\":\"2020-05-18 05:25:37 UTC\",\"day\":[1,5,3],\"on\":[\"monday\",\"friday\",\"wednesday\"]}"

Any pointers would be greatly appreciated!

anastasiiatulentseva commented 4 years ago

"day\":[1,5,3],\"on\":[\"monday\",\"friday\",\"wednesday\"]}"

Why are you using day and on together? Maybe that's the issue?

gupta-ankit commented 4 years ago

@adambedford How are you rendering the json for the API response?

rossta commented 3 years ago

Thanks for your question. I'm not able to reproduce this issue. If you can provide steps to repro, we can reopen.