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
Dash defaults not working with ActiveSupport's as_json #362
Comments
Looks legit. You should PR a (failing) spec. |
done in #363 |
I found what causes this problem. Proc is evaluated first time only when property is directly called. #as_json method from active_support doesn't get values but just goes through hash using #map and call as_json for each value. So it tries to call as_json in Proc, it isn't defined and because of it uses as_json of Object which leads to collect its instance_variable and return {} since there is no variables. I see two ways of solving it: evaluate proc in time of initialization or monkey patch something (add as_json method to Proc or do something with ActiveSupport patches). |
I'm against monkey patching FWIW ;) |
Maybe default procs should be evaluated when object is initialized? Method #values also returns procs and i think it's weird because #[] and #values should return same values. |
I am not sure @sazor, try to PR something and we can see what specs that breaks ;) |
Closed via #380. |
I'm not sure if this is a Hashie or ActiveSupport problem. I would expect fields to be an array, not a hash when as_json is used. It works fine if I don't use a proc for the default.
The text was updated successfully, but these errors were encountered: