How can _know_ which JSON renderer is active in my Rails 3 app?

json, ruby-on-rails-3

Solution

Instead of fiddling with your controller, a better way is to use the Rails console, like so:

$ rails console
Loading development environment (Rails 3.2.8)
1.8.7 :001 > MultiJson.engine
 => MultiJson::Adapters::JsonGem 

You can interact directly with your Rails stack that way.

Problem

This is a direct follow-on to this question: What is the fastest way to render json in rails? My app does a database query and render to JSON for a JS callback. It takes at least 8 seconds for a small (1 MB) dataset, and more like 20 for a large (3.5 MB) one. This is basically going to kill my app as an idea. My users aren't going to put up with this sort of wait. I've read about multi_json and oj and yajl, and I think I've got them installed, but none of the ways I've tried to activate the various gems in my Gemfile show any improvement in serializing time. How can I prove that I'm using one over the other, so that I compare results between them? I can't find any way of outputting (to the Rails debug log or the JS console in the browser) which library might have gotten used for the actual 'render :json => @data' call.

Original source

Related problems