Ruby on rails Rails嵌套布局不工作,空白页
我尝试在Rails中使用嵌套布局,比如,但它不起作用。它显示了一个空白页。当我检查页面源代码时,它是空的。日志中没有任何错误:Ruby on rails Rails嵌套布局不工作,空白页,ruby-on-rails,ruby,ruby-on-rails-5,Ruby On Rails,Ruby,Ruby On Rails 5,我尝试在Rails中使用嵌套布局,比如,但它不起作用。它显示了一个空白页。当我检查页面源代码时,它是空的。日志中没有任何错误: Started GET "/" for 127.0.0.1 at 2018-03-19 16:36:30 -0300 Processing by ComingSoonController#index as HTML Rendering coming_soon/index.html.erb within layouts/coming Rendered coming
Started GET "/" for 127.0.0.1 at 2018-03-19 16:36:30 -0300
Processing by ComingSoonController#index as HTML
Rendering coming_soon/index.html.erb within layouts/coming
Rendered coming_soon/index.html.erb within layouts/coming (5.1ms)
Rendering layouts/application.html.erb
Rendered layouts/application.html.erb (42.5ms)
控制器:
class ComingSoonController < ApplicationController
layout 'coming'
def index
end
end
类ComingSoonController
views/comming_soon/index.html.erb
<% content_for :simple_content do %>
<div>
content here
</div>
<% end %>
满足于此
视图/布局/coming.html.erb
<% content_for :content do %>
teste
<%= yield(:simple_content) or yield %>
<% end %>
<% render :file => 'layouts/application' %>
睾丸
'布局/应用程序'%>
视图/布局/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>some title</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_tag do %>
window.userSignedIn = <%= user_signed_in? %>;
<% end %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Exo+2" rel="stylesheet">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="theme-color" content="#000000">
<%= favicon_link_tag 'logo.ico' %>
</head>
<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<% if current_user %>
<%= link_to "Sair", destroy_user_session_path, method: :delete %>
<% else %>
<%= link_to "Registrar", new_user_registration_path %>
<%= link_to "Login", new_user_session_path %>
<% end %>
<%= yield(:content) %>
</body>
</html>
一些头衔
window.userSignedIn=;
你知道发生了什么事吗
多谢各位
===================================
更新
解决方案:我不得不更改“layouts/application”>我更改了,但要测试的问题相同-将一些内容放在
块的内容之外,以确保正确呈现模板+布局。。。它应该出现在页面上。您还应该在此处查看呈现嵌套布局的最新版本:如果您的模板中有任何更改,请尝试一下,可能一切都正常…显然,问题与文件视图/layouts/coming.html.erb有关,因为如果我将控制器更改为使用布局视图/layouts/application.html.erb(布局“应用程序”),并将文件视图/comming_-soon/index.html.erb更改为它可以工作,现在就可以了。我必须更改“布局/应用程序”%>。我以前做过,但我用的是