2013-06-27 187 views
1

您好我在渲染部分軌道視圖時遇到問題。Ruby On Rails渲染部分

我在views/layouts目錄中創建了一個名爲_my_header.html.erb的部分。

然後在名爲index.html.erb意見的不同文件夾中的另一個文件我補充:

<% render 'layouts/my_header' %> 

我把這個HTML標籤內。反正我收到此錯誤:

ActionView::MissingTemplate in User#index 

Showing C:/Buzzoo/Buzzoo/app/views/user/index.erb where line #2 raised: 
Extracted source (around line #2): 

1: <html> 
2: <% render 'layouts/my_header' %> 
3: 
4: <body> 
+1

你能分享你的部分內容嗎?我想知道這個錯誤是否存在,儘管有錯誤信息。 –

回答

0

ActionView::MissingTemplate in Player#index Showing C:/Buzzoo/Buzzoo/app/views/player/index.mobile.erb where line #2 raised: Missing partial /layouts/mobile_header with {:locale=>[:en], :formats=>[:mobile], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "C:/Buzzoo/Buzzoo/app/views" * "C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-2.1.2/app/views" Extracted source (around line #2): 1: 2: <%= render '/layouts/mobile_header' %> 3: 4:

@ user2527785

上述錯誤指定在mobile_header的名稱中沒有部分。您確定自己的佈局中有部分_mobile_header.mobile.erb

1

<%= render 'layouts/my_header' %>您需要使用<%= %>代替<% %>,當你想Ruby代碼顯示在水木清華您的模板。

1

剛剛嘗試下面的代碼

<%= render '/layouts/my_header' %> 
+0

::的ActionView在MissingTemplate播放#索引 顯示C:/Buzzoo/Buzzoo/app/views/player/index.mobile.erb其中線#2提出: 缺少含{局部/佈局/ mobile_header:區域設置=> [:en],:formats => [:mobile],:handlers => [:erb,:builder,:coffee]}。搜索: *「C:/ Buzzoo/Buzzoo/app/views」 *「C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-2.1.2/app/views 「 提取的源(圍繞線#2): 1: 2:\t <%=渲染 '/佈局/ mobile_header' %> 3: 4:\t 5: – user2527785

+1

請檢查連結http: //stackoverflow.com/questions/339130/how-do-i-render-a-partial-of-a-different-format-in-rails#answer-6181539 –