Jae Lee
2014-Feb-07 12:38 UTC
is nested json structure supported for activerecord - postgresql?
Hi all,
I'm using rails 4.1.0.beta 1 and postgresql 9.3.1 and its native support
for json column. so no special serializer or no special storage thing with
active record, just plain :json type in active record migration.
in my active record model, I've got two json fields.
input: {"first_name"=>"firstName",
"last_name"=>"lastName",
"postcode"=>"postcode"}
output:
{"customer_detail"=>{"first_name"=>"firstName",
"last_name"=>"lastName",
"postcode"=>"postcode"}}
model.input
=> {"first_name"=>"firstName",
"last_name"=>"lastName",
"postcode"=>"postcode"}
model[:input]
=> {"first_name"=>"firstName",
"last_name"=>"lastName",
"postcode"=>"postcode"}
model.input_before_type_cast
=> "{\"first_name\":\"firstName\",
\"last_name\":\"lastName\",
\"postcode\":\"postcode\"}"
model.output
=> nil
model[:output]
=>
{"customer_detail"=>{"first_name"=>"firstName",
"last_name"=>"lastName",
"postcode"=>"postcode"}}
model.output_before_type_cast
=>
"{\"customer_detail\":{\"first_name\":\"firstName\",\"last_name\":\"lastName\",\"postcode\":\"postcode\"}}"
could someone explain why this is happening? I'm confused why this is
happening...
thanks!
J
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/b7573b25-0652-4dc8-a61d-f8c0bc883b9b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.