页面#home中的MissingTemplate

时间:2016-05-04 22:47:49

标签: ruby ruby-on-rails-4

我尝试在 localhost:3000 / pages / home 上打开我的主页博客,我在Pages#home中收到此错误消息:Missing Template`。我不知道我错过了什么。红宝石还是比较新的。我之前在我的主页上添加了一个额外的链接,也许这就是原因。我的 home.html.erb 的代码如下。我们非常感谢您的帮助。

<h1>this the alpha-blog page</h1>
<h2>Spectacular Mountain</h2>
<img src="pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">
<%= link_to "Alpha-blog", articles_path %> |<%=link_to"About",about_path %>


Action View::Missing Template in Pages#home
Showing /home/nitrous/code/rails_projects/alpha-blog/app/views/layouts/application.html.erb where line #10 raised:

Missing partial layout/_messages with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:

* "/home/nitrous/code/rails_projects/alpha-blog/app/views"
Extracted source (around line #10):
8
9
10
11
12
13

</head>
<body>
<%= render 'layout/messages' %>
<% yield% >

</body>

Rails.root: /home/nitrous/code/rails_projects/alpha-blog

Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__148494832947707035_40406660'

我的** config / routes.rb *看起来像这样

Rails.application.routes.draw do
  root 'pages#home'
  get 'about', to:'pages#about'
  resources :articles
end

1 个答案:

答案 0 :(得分:3)

在您的代码中,您致电

<%= render 'layout/messages' %>

但是你没有包含文件&#34; _messages.html.erb&#34;在&#34; app / views / layouts&#34;夹。只需创建一个&#34; _messages.html.erb&#34;在layouts文件夹中的文件,你应该很高兴。