This project is archived and is in readonly mode.
exception_class.to_json == "{\"inheritable_attributes\":{}}"
-
Prem Sichanugrist (sikachu)
- State changed from new to wontfix
- Importance changed from to Low
Hi,
From your report, I think you are suggesting that Rails'
to_jsonshould have the same outcome as pureirb, right?I can confirm the above outcome on Rails 3.0.1. However, I don't think this is a bug, as this is the way Rails make sure that everything can be converted to JSON. Calling
to_jsonon an object would actually callingto_hashor returninginstance_valuesif it doesn't implementsto_hash. Unintentionally,StandardErrordoesn't implementsto_hash, and so you got the instance variables (or class variables, in this case) instead. -
Prem Sichanugrist (sikachu)
One more thing,
and you saw
inheritable_attributesin the list of attributes because that's actually a hash storing the list of class's inheritable attributes. -
Greg Hazel
Why should Rails to_json work any differently than regular to_json for non-Rails objects?
Also, as you can see from Marshal, there is no need to dump anything about
inheritable_attributesin order to instantiate StandardError again.>> Marshal.dump(StandardError) => "\004\bc\022StandardError" >> Marshal.load(Marshal.dump(StandardError)) => StandardError