Having to explicitly render :layout => 'application' in controller actions in my Rails 3 app

别等时光非礼了梦想. 提交于 2019-12-22 09:07:40

问题


I am having to explicitly render :layout => 'application' in my controller actions in order to get my new rails 3 app to actually use the application.html.erb layout file.

Any obvious things to look for that I am doing wrong? If I don't call the :layout option it just doesn't render the layout. I get a message like:

Processing by FooController#index as HTML

...when I read the terminal window trace on WEBrick


回答1:


I experienced the same problem with an app upgraded from Rails 2.3.8 to 3.0.3. In my case, all controllers except one rendered properly with the app/views/layouts/application.html.haml. When I finally added render :layout => 'application', the non-conforming controller rendered properly.




回答2:


I know this is resing a dead thread but I recently ran into the same issue. My controller was inheriting from ActionController::Base and not ApplicationController. I had the same issue as you were having, until I fixed that.




回答3:


I ran into the same issue, the problem ended up being that someone had defined an initialize method for the controller.



来源:https://stackoverflow.com/questions/3994327/having-to-explicitly-render-layout-application-in-controller-actions-in-my

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!