Rails 3.2 - 应用程序中的每个操作都会加载两次

发布于 2025-01-07 17:54:37 字数 739 浏览 0 评论 0原文

当我查看终端的输出时(我在本地主机上使用服务器 WEBRick),我看到每个操作(无论什么控制器)总是被调用两次(第二个操作总是在第一个操作之后 1-2 秒) 。

难道没有人遇到同样的问题吗?我尝试在 Google 上搜索,并在此处进行讨论,但不幸的是我没有找到任何有用的帮助...

编辑 - 示例: 当我查看终端输出时,我会看到例如:

Started GET "/articles" for 127.0.0.1 at 2012-02-22 01:35:42 +0100
Processing by ArticlesController#index as HTML
...sql queries...
Completed 200 OK in 1690ms (Views: 1451.2ms | ActiveRecord: 28.7ms | Solr: 203.8ms)

Started GET "/articles" for 127.0.0.1 at 2012-02-22 01:35:45 +0100
Processing by ArticlesController#index as */*
...sql queries...
Completed 200 OK in 159ms (Views: 105.8ms | ActiveRecord: 2.8ms | Solr: 49.0ms)

这适用于我的应用程序控制器中的每个操作。在浏览器中一切正常,访问者对重复加载操作一无所知,但是您知道......为什么会重复加载操作?

When I take a look into the terminal's output (I use server WEBRick on my localhost), so I see there that every action (no matter what controller) is called twice, always (the second one always 1-2 seconds after the first).

Didn't has anyone the same problem? I tried to search on Google and also a discussions here on SO, but unfortunately I didn't find any useful help...

EDIT - example:
when I take a look into the terminal output, so I see there for example:

Started GET "/articles" for 127.0.0.1 at 2012-02-22 01:35:42 +0100
Processing by ArticlesController#index as HTML
...sql queries...
Completed 200 OK in 1690ms (Views: 1451.2ms | ActiveRecord: 28.7ms | Solr: 203.8ms)

Started GET "/articles" for 127.0.0.1 at 2012-02-22 01:35:45 +0100
Processing by ArticlesController#index as */*
...sql queries...
Completed 200 OK in 159ms (Views: 105.8ms | ActiveRecord: 2.8ms | Solr: 49.0ms)

This is for every action in controllers of my app. In the browser is everything ok, a visitor don't know nothing about repeated loading the action, but you know... why is there repeated loading of an actions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

第七度阳光i 2025-01-14 17:54:37

如果这是一个 ajax 请求,则可能是由于 javascript 文件被包含两次而导致的。您可能已在开发模式下预编译了您的资源。您可以尝试删除“//= require_tree 。”来自 application.js

If this is an ajax request it could be caused by the javascript files being included twice. You may have precompiled your assets in development mode. Could you try removing "//= require_tree ." from application.js

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文