This project is archived and is in readonly mode.

#5841 ✓resolved

Unexpected behavior of render :json => obj

Reported by johnnypez | October 19th, 2010 @ 05:19 PM | in 3.x

I hit this unexpected behaviour I call render :json => obj in my controller and also using respond_with obj where JSON output is expected.
I have tracked this down to

json = ActiveSupport::JSON.encode(json, options) unless json.respond_to?(:to_str)
So the object is not encoded to JSON if it responds to :to_str. That doesn't make any sense to me.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>


Referenced by