html - 删除网站上的意外内容

标签 html css ruby-on-rails ruby

在关注 tutorial 时在构建 Ruby-on-Rails 博客网站时,我遇到了一些意想不到的结果。目前的元素存储在 https://github.com/khpeek/jumpstart-blogger 上.

主页是一个“文章”页面,如下所示:

enter image description here

到目前为止,一切都很好(除了“创建新文章”按钮有点奇怪的位置,它曾经位于文章的正下方)。

“所有文章”的外观由 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 标签的文章”,我会看到以下页面:

enter image description here

除了包含文章、标签和评论的所需框外,还有两个提交按钮和“<< 返回文章列表”按钮,这些按钮既不是您想要的,也不是您想要的。

据我了解,此页面的外观由 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/

相关文章:

javascript - 移动页面在顶部时div垂直居中,但是当我们向下滚动页面时,出现错误

javascript - 我使用 MDL 得到 2 个滚动条,我该如何修复它?

ruby-on-rails - Emacs session /项目/窗口管理

javascript - 使用 window.frames 属性获取 iframe 与 iframe ID

javascript - 如何将 javascript 变量值分配给文本框 - 在 PHP 中

html - 尝试交换标签的顺序会改变 Bootstrap/CSS 的功能

ruby-on-rails - rails 如何渲染具有正确文件名的文件

ruby-on-rails - 将现有的 ROR 应用程序迁移到 GAE

php - 如果我的网站被盗,通知我的代码

html - 将 Logo 图像居中并将响应式导航栏放在 Logo 正下方