Controller#index is getting called immediately after every single other call

This is a very odd problem, it's been happening, I think, ever since I patched to Rails 2.1.0

Every time a public method gets called in my Controller, the index method gets called immediately afterwards. It's not in my code, and my best guess after testing it on two pretty different machines is, it's not my browser settings either. My cookies and sessions seem to be working fine, DB isn't behaving oddly.

In absence of a direct answer, I'm wondering if someone can tell me how to get Rails Logger (or equivalent) to spit out a complete stacktrace. I'm sure if I could just see where the heck that call is coming from, I could solve the rest of it.

Thanks very much,

Bret

Bret H wrote:

This is a very odd problem, it's been happening, I think, ever since I patched to Rails 2.1.0

In absence of a direct answer, I'm wondering if someone can tell me how to get Rails Logger (or equivalent) to spit out a complete stacktrace. I'm sure if I could just see where the heck that call is coming from, I could solve the rest of it.

Thanks very much,

Bret

You should find your logs at /log in your rails app folder. There should be 3 files, one for each environment mode (test / dev / prod), they are automatically filled up with request information.

Guillaume Petit

Hi, thanks for the suggestion.. my experience so far is that information only gets written to the log when I write it explicitly with a call like

Logger.debug("sometext")

I'm not sure how I could capture the information I need given this limitation. Any ideas?

Well you got it right :slight_smile:

Every controller in rails has a logger *automatically* instanciated for them.

Simply use the logger.info("information to log"), (or .debug, .warn, etc ...) like you used to in other language to log more information. It's a lowercase "l"

Since we are in logging, try to call the method .inspect on any object you wish to look at, that will produce a nice string with your object information, very handy when it comes to logging :slight_smile:

I don't know much in logging with rails, but so far, that was more than enough :slight_smile:

Guillaume Petit

Ah, well I solved my problem. The method I needed is Kernel.caller(start=1).. returns a series of strings roughly approximating a stacktrace starting with the scope in which caller is called.

Thanks for taking the time, though, Guillaume,

Bret