How to find the rails controller responsible for generating data for the current view?

Many a time, it’s essential to find the rails controller being called to render the current view’s JSON. Here’s a simple way to do it.

  1. Go to the Network tab(according to your browser) and look for the ajax request which is fetching the data.

  2. Check the value of x-discourse-route in response headers. It’s in the format controller/action.