虽然在构建Ruby-on-Rails博客网站时遵循tutorial,但我遇到了一些意想不到的结果。迄今为止的项目存储在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
头,但“意外”的内容似乎来之前那。所以我很难看到从哪里开始删除这些内容。任何指针?