-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from_hash expects keys to be symbols - serialized data normally string keys #93
Comments
Heya - What JSON library are you using, 'json'? In the meantime you can fix the problem with opt = { 'a' => { 'b' => 2 } } # or JSON.parse(data)
opt.deep_symbolize_keys!
IceCube::Schedule.from_hash opt |
I'm using |
I totally thought |
Nope - and you can either use a opt = { 'a' => { 'b' => 2 } }.deep_symbolize_keys
IceCube::Schedule.from_hash opt |
It seems like these methods only exist on Rails master, not on stable (even on 3.2.7)
could you elaborate on this |
I have been having some issues with the
from_hash
method.My data is serialized into json and stored in the database - then fetched out as a string and parsed to a hash.
This breaks
from_hash
because it is expecting symbols as keys.There would be a simple fix to throw on a
symbolize_keys
but unfortunately there are nested hashes inside the serialized hash. This makes me have to write my own handler to recursively symbolize keys in the nested hashes which seems excessive.It seems like the common use case to serialize the schedule into a string and then parse it (probably more often than not from a JSON encoded string).
Is there a good reason for the default behavior? Am I doing it wrong?
I will provide examples upon request.
Thank you!
I don't know what I would do without this project :)
The text was updated successfully, but these errors were encountered: