Rails 3.1:视图未在命名空间布局中呈现
在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
<%= yield %>
可能会有所帮助,伙计<%= yield %>
might help there, mate