Rails正在生成html之前<;DOCTYPE
我不明白这是怎么发生的。在我的页面上显示源代码是这样开始的——是的,这就是html的开始,我在Chrome和Safari中仔细检查了它Rails正在生成html之前<;DOCTYPE,html,ruby-on-rails,views,Html,Ruby On Rails,Views,我不明白这是怎么发生的。在我的页面上显示源代码是这样开始的——是的,这就是html的开始,我在Chrome和Safari中仔细检查了它 </div> </div> </div> <!DOCTYPE html> <html> <head> <title>Rstest</title> <link href="/assets/application.css?body
</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 %>
</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>
<% 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' %>
<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 :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 %>
<!--not here -->
</div>
</div>
</div>
<% end %><!--but here -->
<%= render :template => 'layouts/application' %>
Rstest
“全部”%>
reptabs.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>
<% 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' %>
<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 :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 %>
<!--not here -->
</div>
</div>
</div>
<% end %><!--but here -->
<%= render :template => 'layouts/application' %>
'布局/应用程序'%>
report.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>
<% 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' %>
<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 :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 %>
<!--not here -->
</div>
</div>
</div>
<% end %><!--but here -->
<%= render :template => 'layouts/application' %>
报告
....
=>
我想知道我是否把语句的内容弄乱了?你应该像这样将循环的内容的结尾向下移动 reptabs.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>
<% 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' %>
<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 :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 %>
<!--not here -->
</div>
</div>
</div>
<% end %><!--but here -->
<%= render :template => 'layouts/application' %>
'布局/应用程序'%>
您应该像这样向下移动内容循环中的结尾
reptabs.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>
<% 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' %>
<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 :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 %>
<!--not here -->
</div>
</div>
</div>
<% end %><!--but here -->
<%= render :template => 'layouts/application' %>
'布局/应用程序'%>
布局文件的名称是application.htmm.erb还是application.html.erb?在任何情况下,我建议您更正问题中的打字错误。您是否检查了在布局文件上方实际添加内容的视图名为application.htmm.erb或application.html.erb?在任何情况下,我建议您更正问题中的打字错误,因为它在您的应用程序中是正确的。您是否检查了在上方实际添加内容的视图?谢谢!这就解决了。。。我承认我不太理解这个布局中的所有代码。。。但我早就知道那是在错误的地方。。。我不知道我是怎么/什么时候做的。谢谢#2:它解决了我在StackOverflow中试图写的另一个问题!没问题。我们都会这样打字谢谢这就解决了。。。我承认我不太理解这个布局中的所有代码。。。但我早就知道那是在错误的地方。。。我不知道我是怎么/什么时候做的。谢谢#2:它解决了我在StackOverflow中试图写的另一个问题!没问题。我们都会这样打字