Rails 3.1:视图未在命名空间布局中呈现

发布于 2024-11-12 04:57:39 字数 571 浏览 4 评论 0原文

在routes.rb中:

namespace :admin do
    root :controller => "base", :action => "index"
    resources :products
end

产品控制器继承自基本控制器:

class Admin::BaseController < ApplicationController
   #layout 'admin'
   def index
   end
end

class Admin::ProductsController < Admin::BaseController
   def index
   end
end

如果没有“layout 'admin'”,两个索引视图都会正常渲染。

使用“layout 'admin'”,会呈现管理布局,但不会呈现视图,尽管 WEBricks 消息如下:

Rendered admin/products/index.html.erb within layouts/admin

In routes.rb:

namespace :admin do
    root :controller => "base", :action => "index"
    resources :products
end

The products controller inherits from the base controller:

class Admin::BaseController < ApplicationController
   #layout 'admin'
   def index
   end
end

class Admin::ProductsController < Admin::BaseController
   def index
   end
end

Without "layout 'admin'", both index views render normally.

With "layout 'admin'", the admin layout is rendered, but the views are not rendered, despite WEBricks message:

Rendered admin/products/index.html.erb within layouts/admin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2024-11-19 04:57:39

<%= yield %> 可能会有所帮助,伙计

<%= yield %> might help there, mate

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文