Rails 应用程序记录重复请求 [英] Rails app logging duplicate requests

查看:37
本文介绍了Rails 应用程序记录重复请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Rails 应用程序,它为开发中的每个请求生成重复的请求.该应用程序运行 Rails 2.3.5,我的主要开发机器运行 Ubuntu 10.4.但是,相同的代码运行良好,而不会在我的 OS X 10.6 机器上显示重复的请求.它也可以在任何一台机器上以生产模式运行,没有问题.

I have a Rails app that is generating duplicate requests for every request in development. The app is running Rails 2.3.5 with my primary development machine running Ubuntu 10.4. However, the same code runs fine without showing duplicate requests on my OS X 10.6 box. It also runs in Production mode on either machine without problems.

  Processing DashboardController#index (for 127.0.0.1 at 2010-07-16 10:23:08) [GET]
  Parameters: {"action"=>"index", "controller"=>"dashboard"}
Rendering template within layouts/application
Rendering dashboard/index
  Term Load (1.9ms)   SELECT * FROM "date_ranges" WHERE ('2010-07-16' BETWEEN begin_date and end_date ) AND ( ("date_ranges"."type" = 'Term' ) ) 
  StaticData Load (1.1ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
  CACHE (0.0ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
Rendered dashboard/_news (0.1ms)
  CACHE (0.0ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
  CACHE (0.0ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
  StaticData Load (0.9ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'TAG_LINE') LIMIT 1
Completed in 67ms (View: 58, DB: 5) | 200 OK [http://localhost/dashboard]
  SQL (0.4ms)   SET client_min_messages TO 'panic'
  SQL (0.4ms)   SET client_min_messages TO 'notice'


Processing DashboardController#index (for 127.0.0.1 at 2010-07-16 10:23:08) [GET]
  Parameters: {"action"=>"index", "controller"=>"dashboard"}
Rendering template within layouts/application
Rendering dashboard/index
  Term Load (1.9ms)   SELECT * FROM "date_ranges" WHERE ('2010-07-16' BETWEEN begin_date and end_date ) AND ( ("date_ranges"."type" = 'Term' ) ) 
  StaticData Load (1.1ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
  CACHE (0.0ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
Rendered dashboard/_news (0.1ms)
  CACHE (0.0ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
  CACHE (0.0ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'SITE_NAME') LIMIT 1
  StaticData Load (0.9ms)   SELECT * FROM "static_data" WHERE ("static_data"."name" = E'TAG_LINE') LIMIT 1
Completed in 67ms (View: 58, DB: 5) | 200 OK [http://localhost/dashboard]
  SQL (0.4ms)   SET client_min_messages TO 'panic'
  SQL (0.4ms)   SET client_min_messages TO 'notice'

请注意,请求完全相同,甚至是时间戳.

Notice that the requests are exactly the same, even down to the timestamps.

我曾尝试使用 Ruby 1.8.7 &1.9.1 以及 Mongrel & 之间的交换Webrick 并且它总是处理每个请求两次(或者至少它生成两个日志条目).我尝试删除大部分路线以查看是否发生了奇怪的事情,但问题仍然存在.我尝试了来自不同机器的不同浏览器(Chrome、Safari、eLinks),看看这是否有帮助,但问题仍然存在.我删除了所有宝石,只更换了必要的宝石,但无济于事.

I have tried using Ruby 1.8.7 & 1.9.1 as well as swapping between Mongrel & Webrick and it always processes each request twice (or at least it generates two log entries). I tried removing most of the routes to see if I had something weird going on, but the problem persists. I tried different browsers (Chrome, Safari, eLinks) from different machines to see if that would help, but the problem persists. I removed all of my gems and only replaced the necessary ones but to no avail.

有谁知道为什么 Rails 会导致这样的重复请求?我几乎无所适从,正在抓紧稻草.唯一的亮点是这种行为不会发生在生产环境下,只会发生在开发环境下.

Does anyone have any idea why Rails would cause duplicate requests like this? I am about at my wits end and am grasping at straws. The only bright spark is that this behavior does not happen under the Production environment, only Development.

推荐答案

问题的答案"是移动到一个新目录并从 Github 获取原始代码.在新目录中配置和设置所有内容后,应用程序可以正常工作,没有重复的请求.还是不明白原目录下的代码为什么会报错;我什至对目录进行了区分,唯一的异常值是日志文件.

The "answer" to the problem was to move to a new directory and fetch the original code from Github. After getting everything configured and setup in the new directory the application works as it should with no duplicate requests. I still don't know why the code in the original directory borked out; I even diff'ed the directories and the only outliers were the log files.

我在这里回答我自己的问题是为了其他可能遇到同样问题的人的理智.

I'm answering my own question here for the sanity of others that might experience the same problem.

这篇关于Rails 应用程序记录重复请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆