This project is archived and is in readonly mode.
JSON serialization is broken
-
José Valim
- Milestone set to 3.x
- Assigned user cleared.
- Importance changed from to Low
Patch with tests please.
-
Kent Sibilev
I've just sent a pull request with my proposed patch. The test to reproduce the problem is below:
require 'rubygems' require 'active_model' require 'active_support/core_ext' require 'active_support/json' class User include ActiveModel::Serialization include ActiveModel::Serializers::JSON attr_accessor :name def attributes @attributes ||= {'name' => 'nil'} end end u = User.new u.name = 'kent' json = { :user => u, :x => { :name => 1 } }.to_json puts json # => {"user":{"user":{"name":"kent"}},"x":{"name":1}} options = {} json = { :user => u, :x => { :name => 1 } }.to_json( options ) puts json # => {"user":{"user":{"name":"kent"}},"x":{}} p options # => {:except=>[], :only=>[]}My ignorance prevents me from implementing proper test cases. Sorry.
-
José Valim
So could you please create a patch from your pull request and attach it here? It will allow other people to create a test case for your patch so it can be finally applied.
-
Kent Sibilev
Here we go. The diff is attached.
-
David Trasbo
FYI: I'm going to start making a test for this now.
-
David Trasbo
There you go:
-
David Trasbo
- Assigned user set to José Valim
-
Adrian
Hello,
Im having trouble overriding the as_json method in one of my models,
Is this issue related to my problem?
Thanks
-
David Trasbo
Adrian,
Maybe, maybe not - I can't tell. Why don't you hop into #railsbridge at irc.freenode.org and ping me there? I'm dtrasbo.
-
Adrian
Thanks David, I'll do that
-
David Trasbo
Awesome. FYI, I'm in there now if you have time.
-
Jeff Kreeftmeijer
- Tag set to json, patch
-
José Valim
Kent, could you please rebase your patch? Sorry but it no longer applies.
-
Kent Sibilev
You can close this ticket, since it looks like the required changes have been submitted already with another patch.
Thanks.
-
José Valim
- State changed from new to resolved
