Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 Rails 3.2.2操作被调用两次_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 3 Rails 3.2.2操作被调用两次

Ruby on rails 3 Rails 3.2.2操作被调用两次,ruby-on-rails-3,Ruby On Rails 3,我的应用程序基于Rails 3.2.2。面临一些奇怪的问题:开发/生产中的所有操作都被调用两次。有什么建议吗 Started GET "/faqs" for 127.0.0.1 at 2012-07-07 17:08:06 +0200 Processing by FaqsController#index as HTML Faq Load (0.5ms) SELECT `faqs`.* FROM `faqs` WHERE `faqs`.`active` = 1 ORDER BY positi

我的应用程序基于Rails 3.2.2。面临一些奇怪的问题:开发/生产中的所有操作都被调用两次。有什么建议吗

Started GET "/faqs" for 127.0.0.1 at 2012-07-07 17:08:06 +0200
Processing by FaqsController#index as HTML
  Faq Load (0.5ms)  SELECT `faqs`.* FROM `faqs` WHERE `faqs`.`active` = 1 ORDER BY position asc
  Rendered faqs/index.html.haml within layouts/application (3.1ms)
  Rendered shared/_navigation_bar.html.haml (5.3ms)
  Rendered devise/registrations/_register.html.erb (5.5ms)
Completed 200 OK in 137ms (Views: 43.3ms | ActiveRecord: 0.5ms | Solr: 0.0ms)


Started GET "/faqs" for 127.0.0.1 at 2012-07-07 17:08:06 +0200
Processing by FaqsController#index as */*
  Faq Load (0.2ms)  SELECT `faqs`.* FROM `faqs` WHERE `faqs`.`active` = 1 ORDER BY position asc
  Rendered faqs/index.html.haml within layouts/application (0.2ms)
  Rendered shared/_navigation_bar.html.haml (3.9ms)
  Rendered devise/registrations/_register.html.erb (12.1ms)
Completed 200 OK in 33ms (Views: 30.2ms | ActiveRecord: 0.2ms | Solr: 0.0ms)

更新#1

简单控制器:

class FaqsController < ApplicationController
  respond_to :html

  def index
    @faqs = Faq.all
    respond_with(@faqs)
  end
end

这个问题可能与Rails 3.2.2没有任何关系


如果页面上有javascript,并且在加载页面时发出ajax请求,则可以看到这种确切的行为。我会浏览你所有的脚本资源,寻找一个在页面加载后可以调用你的应用程序的资源。你可能会在那里找到罪魁祸首。

这可能是因为Chrome。您可以在Safari/Firefox/IE等中进行测试

我认为它导致两次加载的原因是因为Chrome“分叉”了请求,实际上发出了两个请求。它渲染在其窗口中返回的第一个


IIRC我在很多年前就研究过这个,这是一个可以更快地呈现页面的功能

看起来可能是jquery rails。在浏览器中调出一个检查器,看看你是否在做一些ajax ey的事情。这些请求针对不同的mime类型:
FaqsController#索引为HTML
FaqsController#索引为*/*
。到底怎么回事@Deanbrindage AJAX没有提出任何请求。c@Zabba这是一款全新的应用程序,所以mime类型没有任何变化。控制器仅用HTML响应。发布
/FAQ
%h2 Faqs
- @faqs.each_with_index do |faq, index|
  .span9  
    %h3
      = "%d." % (index + 1)
      = faq.title
    %p= faq.body