我是 Rails 的初级开发人员,我正在对使用 Ruby 1.8.7 和 Rails 3.0.3 开发的应用程序进行系统研究。在我的应用程序中,我有一个带有 application.html.erb 布局的 application_controller 和一个带有 home_html.erb 的 home_controller> 布局以及 CRUD View 。然后在我的 routes.rb 中,默认路由设置如下所示,以及回家的足智多谋的路由。
root :to => 'home#index'
资源:主页
在 application.html.rb 中,我们有默认布局要呈现在其中,需要使用 <%= yield %> 插入其他 View 。但我有另一个名为 home.html.erb 的布局,其内容与 application.html.erb 的内容相同。当我运行该应用程序时,默认布局是从 home.html.erb 而不是 application.html.erb 加载的。可能是什么原因?
最佳答案
在你的 Controller 中写
class TetsController < ApplicationController
layout "layout_name"
#...
end
关于ruby-on-rails - 不呈现 Rails 3 中的默认应用程序布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14356207/