我有我的布局看起来像这样:重新定义布局块3
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta charset="UTF-8">
<title>My title</title>
<%= stylesheet_link_tag "general" %>
<%= javascript_include_tag "libs/jquery-1.5.1.min" %>
<%= csrf_meta_tag %>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/favicon.ico">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<% if flash[:notice] %>
<% if flash[:notice].kind_of?(Array) %>
<% flash[:notice].each do |id, value| %>
<p><%= id =%> <%= value =%> </p>
<% end %>
<% else %>
<p><%= flash[:notice] =%></p>
<% end %>
<% end %>
<% if flash[:error] %>
<p class="error"><%= flash[:error] %></p>
<% end %>
<!-- more content -->
<div id="principal">
<%= render 'layouts/header' %>
<%= render 'layouts/banner' %>
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
我的问题是这样的一行:
<%= render 'layouts/banner' %>
我在网站顶部的横幅。我想在每一页上更改它。我怎么能从我的控制器的index.html.erb视图覆盖这个渲染器例如?
谢谢大家帮忙
无需调用yield两次,并检查“空?”。有一个'content_for?'谓词。 – d11wtq
不错,谢谢@ d11wtq。 – bricker