在关注 tutorial 时在构建 Ruby-on-Rails 博客网站时,我遇到了一些意想不到的结果。目前的元素存储在 https://github.com/khpeek/jumpstart-blogger 上.
主页是一个“文章”页面,如下所示:
到目前为止,一切都很好(除了“创建新文章”按钮有点奇怪的位置,它曾经位于文章的正下方)。
“所有文章”的外观由 app/views/articles/index.html.erb
管理,内容为
<h1>All Articles</h1>
<ul id="articles">
<% @articles.each do |article| %>
<li>
<%= link_to article.title, article_path(article), class: 'article_title' %>
</li>
<% end %>
</ul>
<%= link_to "Create a New Article", new_article_path, class: "new_article" %>
h1
标题是 .html.erb 文件中的第一个内容,也是出现在网页上的第一个内容。
但是,如果我单击文章链接,说“带有 Ruby 标签的文章”,我会看到以下页面:
除了包含文章、标签和评论的所需框外,还有两个提交按钮和“<< 返回文章列表”按钮,这些按钮既不是您想要的,也不是您想要的。
据我了解,此页面的外观由 app/views/articles/show.html.erb
管理,内容为
<h1><%= @article.title %></h1>
<p>
Tags:
<% @article.tags.each do |tag| %>
<%= link_to tag.name, tag_path(tag) %>
<% end %>
</p>
<% if @article.image.exists? %>
<p><%= image_tag @article.image.url %></p>
<% end %>
<p><%= @article.body %></p>
<h3>Comments (<%= @article.comments.size %>)</h3>
<%= render partial: 'articles/comment', collection: @article.comments %>
<%= render partial: 'comments/form' %>
<%= link_to "<< Back to Articles List", articles_path %>
<% if logged_in? %>
<%= link_to "delete", article_path(@article), method: :delete, data: {confirm: "Really delete the article?"} %>
<%= link_to "edit", edit_article_path(@article) %>
<% end %>
此文件的第一行是h1
header ,但“意外”内容似乎出现在此之前。所以我不知道从哪里开始删除这些内容。有什么指点吗?
最佳答案
您正在处理布局 Rails 的概念。 Read this .
无论如何,您可能在 app/views/layouts
中有一个布局文件。
关于html - 删除网站上的意外内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37984654/