Herman
2012-May-21 23:47 UTC
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.