我正在创建基于Device模板的模块化Rails模板的过程。我主要的应用程序布局:Rails渲染视图如果文件存在
application.html.erb
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "Rails Devise" %></title>
<meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Rails Devise" %>">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<header>
<%= render 'layouts/navigation' %>
</header>
<main role="main">
<%= render 'layouts/messages' %>
<%= yield %>
</main>
<footer>
<% if File.exist?('layouts/footer') %>
<%= render 'layouts/footer' %>
<% end %>
</footer>
</body>
</html>
我有,我想包括:如果文件存在(它可能不是)页脚模板:
_footer.html.erb
<p class="text-muted">
© <%= Time.now.year.to_s %> All rights reserved
</p>
File.exist?当它在那里时不会渲染页脚。只有在模板文件存在的情况下,我如何才能包含页脚?