[Rails] how to not encode only one attribute of model when calling render :json => model
Cross post from SO, hoping to get more insight here.
I've got a column called message in one of my model (UserMessage) in
rails. Now message can contain emoticon value which I passed in from
an iphone app.
For example, the smiley icon has the unicode value of U+1F604 and
since it's passed in with json format, it's serialize to "\u{1F604}"
in my database (postgres).
Now all is fine until I call render :json => @user_message in my
controller. Rails take the serialized message "\u{1F604}" and call
ActiveSupport::JSON.encode on it and therefore encode it again. I've
try to override to_json in the UserMessage class to no avail.
Can someone please point me to the right direction?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home