不在Rails 3中渲染默认应用程序布局

Raj*_*tan 2 ruby layout default ruby-on-rails

我是Rails的入门开发人员,我正在使用Ruby 1.8.7和Rails 3.0.3开发的应用程序的系统研究.在我的应用程序,我有application_controllerapplication.html.erb布局和home_controllerhome_html.erb与CRUD意见一起布局.然后在我的routes.rb中,默认路由设置如下,以及home的资源路由.

root:to =>'home #index'

资源:家

application.html.rb中,我们有一个默认的布局要在其中呈现,其中需要使用<%= yield%>插入其他视图.但我有另一个名为home.html.erb的布局,其内容与application.html.erb的内容相同.当我运行应用程序时,默认布局是从home.html.erb而不是application.html.erb加载的.可能是什么原因?

Sac*_*n R 5

在你的控制器写

   class TetsController < ApplicationController
      layout "layout_name"
      #...
    end
Run Code Online (Sandbox Code Playgroud)