[英]Render Application Layout in Rails Engine
I'm using the Forem engine and have a _header.html.erb
partial in my main application.我正在使用 Forem 引擎并且在我的主应用程序中有一个
_header.html.erb
部分。 How would I render this partial in Forem's view?我将如何在 Forem 的视图中呈现这个部分?
I'd rather not duplicate the code in the view.我宁愿不在视图中复制代码。
我对Forem不太熟悉,但是您不能在.emb视图中添加.erb扩展名,然后照常渲染部分视图吗?
<%= render 'layouts/header' %>
I saw this answer : you have to tweak initializers/forem.rb like this: 我看到了这个答案:您必须像这样调整initializers / forem.rb:
Rails.application.config.to_prepare do
Forem.layout = "application"
end
And it works for me and I have some partials in my app. 它对我有用,我的应用程序中有部分内容。 Is that good for you ?
那对你有好处吗? No answer ?
没有答案 ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.