Displaying Rails Code for SQL Statements
I am reading the code of an open source Rails project and I see SQL statements in the development log that I cannot match against the Rails code i.e. I have no idea where it is called from. I tried ruby-debug, but it doesn't seem to be in sync with the log file output and the code itself, so it's not overly useful. Any suggestions for debugging?
Someone asked which open source project is Insoshi, and here's a snippet of SQL statements I'm trying to map to Rails code.
←[4;36;1mForum Columns (0.0ms)←[0m ←[0;1mSHOW FIELDS FROM `forums`←[0m
←[4;35;1mSQL (15.0ms)←[0m ←[0mSELECT count(*) AS count_all FROM `forums` ←[0m
←[4;36;1mForum Load (0.0ms)←[0m ←[0;1mSELECT * FROM `forums` LIMIT 1←[0m
I don't think the above information is helpful if you don't already know the code, but it doesn't matter here. I didn't show the Rails code because I don't know where it was calling from. This is a common debugging problem that I'm going to run through code when I figure out how it works.
source to share
The rails-footnotes plugin is quite development friendly. It will tell you what requests were used to create the page and also provide a list of available files. Which, by the way, can be modified to open in your favorite editor when clicked in the browser.
source to share