我無法理解這是怎麼發生的。我的網頁上顯示源開始這樣的 - 是的,這是HTML的一開始,我有雙重檢查它在Chrome和Safari ...Rails在生成HTML之前<DOCTYPE
</div>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<title>Rstest</title>
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/bootstrap_and_overrides.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/custom.css?body=1" media="all" rel="stylesheet" type="text/css" />
然而,我application.html.erb開始喜歡這個:
<!DOCTYPE html>
<html>
<head>
<title>Rstest</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
我想不出,將導致此情景......
這裏有一些更多的細節,從日誌:
Rendered reports/report.html.erb within layouts/reptabs (1093.5ms)
Rendered layouts/application.html.erb (12.8ms)
這裏是相關的觀點:
application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>Rstest</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<header class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<%= link_to "Repeat Survey", '#', id: "logo" %>
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "About", '#' %></li>
<li><%= link_to "Contact", '#' %></li>
<li><%= link_to "Help", '#' %></li>
</ul>
</nav>
</div>
</div>
</header>
<div class="container">
<%= content_for?(:content) ? yield(:content) : yield %>
</div>
</body>
</html>
reptabs.html.erb:
<% content_for :content do %>
<div class="container">
<ul class="nav nav-tabs">
<li><%= link_to "Reports", report1_path(@program_id) %></li>
<li><%= link_to "Settings", edit_program_path(@program_id) %></li>
<li><%= link_to "Rounds", program_rounds_path(@program_id) %></li>
<li><%= link_to "Participants", program_participants_path(@program_id) %></li>
<li><%= link_to "Questions", program_questions_path(@program_id) %></li>
</ul>
<div class="container">
<div class="row">
<div class="span2">
<ul class="nav nav-pills nav-stacked">
<li><%= link_to("q r p", report1_path(@program_id)) %></li>
<li><%= link_to("r q p", report2_path(@program_id)) %></li>
<li><%= link_to("p r q", report3_path(@program_id)) %></li>
<li><%= link_to("p q r", report4_path(@program_id)) %></li>
</ul>
</div>
<div class="span9">
<%= content_for?(:reptabs_content) ? yield(:reptabs_content) : yield %>
<% end %>
</div>
</div>
</div>
<%= render :template => 'layouts/application' %>
report.html.erb:
<h2>Report</h2>
<p>
<%= @presenter.to_s %>
</p>
<table class="table table-striped">
<thead>
<tr>
<th>....</th>
<% @presenter.headers.each do |hdr| %>
<th><%= hdr %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @presenter.rows.each do |row_instance| %>
<tr>
<td><%= @presenter.row_label(row_instance) %></td>
<% @presenter.cols.each do |col_instance| %>
<td>
<%= @presenter.cell(row_instance, col_instance).count %> =>
<%= @presenter.cell(row_instance, col_instance).join(", ") %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
我不知道我是否在用我的content_for語句搞亂了一些東西?
佈局文件被命名爲application.htmm.erb或application.html.erb?在任何情況下,我建議你改正錯誤的錯誤是它在你的應用程序中是正確的。 –
錯字,謝謝,修正。 – pitosalas
你檢查過哪個視圖實際上在'
HungryCoder