我的应用程序基于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
视图也很简单:
%h2 Faqs
- @faqs.each_with_index do |faq, index|
.span9
%h3
= "%d." % (index + 1)
= faq.title
%p= faq.body