Question

I'm encountering a rather weird problem. I have the following test in one of my routes:

error 404 unless Agreement.find_by(agreement_id: params[:agreement_id])

This is an active record model, and I just use the provided find_by method. When I inspect the log, this is the output:

D, [2014-03-25T09:40:06.207120 #5956] DEBUG -- :   Agreement Load (0.1ms)  SELECT "agreements".* FROM "agreements" WHERE "agreements"."agreement_id" = '<id>' LIMIT 1
127.0.0.1 - - [25/Mar/2014:09:40:06 +0100] "HEAD /agreements/<id> HTTP/1.1" 204 0.0142
D, [2014-03-25T09:40:06.216059 #5956] DEBUG -- :   Agreement Load (0.2ms)  SELECT "agreements".* FROM "agreements" WHERE "agreements"."agreement_id" = '<id>' LIMIT 1

So, it seems to me that one of two things is happening: either the database is called twice (bad) or it's simply being logged twice (however, this doesn't seem to be the case since the queries apparently are not run at the same pace (0.1ms versus 0.2ms)).

Any help would be greatly appreciated.

Was it helpful?

Solution

It turned out that the application did indeed get called twice, but this was due to buggy middleware code which invoked @app.call twice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top