Ruby on Rails Friday, February 7, 2014

ah don't worry I've realised it was my own error...

J

On Friday, February 7, 2014 12:38:14 PM UTC, Jae Lee wrote:
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/946c4202-5081-497a-87e1-a974c81ec1a2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment