2013-06-27 190 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 –