2016-05-04 20 views
0

我試圖打開我的主頁博客上本地主機:3000 /頁/家,我得到這個錯誤信息:缺少Template`在頁面#回家。我不知道我錯過了什麼。紅寶石還是相當新的。我之前在我的主頁中添加了一個額外的鏈接,也許這就是原因。下面是我的home.html.erb的代碼。您的幫助被尋求和高度讚賞。MissingTemplate在頁面#家

<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 

回答

3

在你的代碼稱爲

<%= render 'layout/messages' %> 

,但你不包括文件「_messages.html。 erb「在」app/views/layouts「文件夾中。只需在layouts文件夾中創建一個「_messages.html.erb」文件,你應該很好。

相關問題