This project is archived and is in readonly mode.
#to_json not working because always being called on Object
Reported by Caio Chassot | May 21st, 2009 @ 06:24 PM | in 2.x
to_json is aliased from rails_to_json on the Object class, while in all other classes (String, Hash, etc.), only rails_to_json is defined.
The overriden rails_to_json methods do not automatically override to_json too.
In the master branch the implementation is a bit different and this is not present, but it is in 2-3-stable.
My patch just defines to_json in Object to call rails_to_json instead of aliasing it.
Comments and changes to this ticket
-
Caio Chassot May 21st, 2009 @ 06:26 PM
- no changes were found...
-
Caio Chassot May 21st, 2009 @ 06:39 PM
you may also pull from me on github, the particular commit is:
http://github.com/kch/rails/commit/ab5750bc081eba31558deecd6234ef35...
-
Caio Chassot May 21st, 2009 @ 06:42 PM
- Tag changed from 2-3-stable, active_support, json to 2-3-stable, active_support, json, patch
-
Caio Chassot May 21st, 2009 @ 06:45 PM
Here's what is currently happen, without the patch:
When you call to json on any ruby object, you get Object#rails_to_json called, which will return a hash of instance variables, so for most objects, like strings, you get an empty hash: "{}"
-
Hongli Lai May 24th, 2009 @ 10:47 AM
Caio Chassot's patch does not seem to correctly pass arguments to #rails_to_json. This patch should fix the problem.
-
CancelProfileIsBroken May 24th, 2009 @ 12:31 PM
- Assigned user set to Pratik
+1 on Hongli's patch. Fixes multiple failures in the Rails test suite that were introduced with http://github.com/rails/rails/commit/2b5e4f38f5d7af912770f8a298ba2e... and currently preventing a clean Rails 2.3 build.
-
Pratik May 25th, 2009 @ 02:35 PM
- State changed from new to resolved
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 2753 #to_json behavior still different between Rails 2.3.2.1 and Rails 2-3-stable Ticket #2690 helped the problems with to_json serializati...