简体   繁体   English

无法正确渲染Rails 4的局部

[英]Not rendering Rails 4 partial correctly

I've upgraded a Rails 3 app to 4 and I'm trying to render some really simple partial thats not working correctly. 我已经将Rails 3应用程序升级到4,并且试图渲染一些无法正常工作的部分。

I'm using HAML and I have a layouts folder with a application.html.haml file inside. 我正在使用HAML,并且我的布局文件夹中包含application.html.haml文件。 Within this file I call several partials that make up the template for the entire page. 在此文件中,我调用了组成整个页面模板的多个部分。 these partials reside in a application folder. 这些部分位于应用程序文件夹中。 For instance, I call: 例如,我称:

= render "chromeframe"

which works perfectly. 完美地运作。 However, below this I have: 但是,在此之下我有:

`= render "header" `=渲染“标题”

which contains a lot of haml html code for the header of the page. 其中包含用于页面标题的大量haml html代码。 My problem is this isn't getting rendered correctly and all I'm getting from that call is" <header id="header"> <h1>Dummy</h1> </header> 我的问题是,这无法正确呈现,而我从该通话中获得的只是“ <header id="header"> <h1>Dummy</h1> </header>

Still fairly new to Rails but I had this working perfectly in Rails 3 so I'm totally thrown by this problem. 对于Rails来说还算是新手,但是我在Rails 3中可以完美地工作,所以我完全被这个问题所困扰。 Any suggestions, I'm sure it's staring me in the face. 有任何建议,我敢肯定它正盯着我。

Thanks 谢谢

Looks like you have a dummy _header.html.xxx or header.html.xxx anywhere in your views, that is found by render. 看起来您的视图中任何地方都有一个虚拟的_header.html.xxxheader.html.xxx ,可以通过render找到。 It doesn't have to be a haml file. 它不必是haml文件。

Look at your deveopment.log . 查看您的deveopment.log It should say Rendered ...header... (xx ms) . 应该说Rendered ...header... (xx ms)
It tells you, where the partial is found. 它告诉您在哪里找到了部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM