开发者

Can't render layout in rails 3

I have an application which was written for rails 2. I'm upgrading to rails 开发者_运维知识库3. Most of the functionality of my app works but it does not render any layout. I'm using default 'erb' engine.

I've explicitly called a layout in my controller but it just does not render even the simplest layout

layout 'application'

It does not throw any error.

When I create a new project and try to render a layout in it, it works perfectly.


The reason that the default layout for the controller isn't being used is because the controller is not properly initialized. This happens when there is an included module in your controller hierarchy that has an 'initialize' method that doesn't call super. This stops the initialize chain and you end up with this sort of problem.

You can read more about it here:

http://www.spiffystores.com/blog/2013/01/04/problems-rendering-a-layout-in-rails3/


You have to use

render :layout => 'application'

You can check it out here :

http://guides.rubyonrails.org/layouts_and_rendering.html

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜