内容简介:我正在创建一个rails应用程序,我必须区分主页的标题.我已经创建了一个部分的_home_header版本和_header版本,以便在每个页面中使用,但我不知道如何管理更改.标题包含在我的布局中,我为每个页面呈现相同的布局.当我请求主页时,如何告诉“布局”使用_home_header版本而不是标准版本?
我正在创建一个rails应用程序,我必须区分主页的标题.
我已经创建了一个部分的_home_header版本和_header版本,以便在每个页面中使用,但我不知道如何管理更改.
标题包含在我的布局中,我为每个页面呈现相同的布局.当我请求主页时,如何告诉“布局”使用_home_header版本而不是标准版本?
我会用current_page吗?帮助器,看看root_path.
# app/views/layouts/application.html.erb
<% if current_page?(root_path) %>
<%= render 'layouts/home_header' %>
<% else %>
<%= render 'layouts/header' %>
<% end %>
翻译自:https://stackoverflow.com/questions/22646048/rails-render-a-different-header-just-on-homepage
以上所述就是小编给大家介绍的《ruby-on-rails – Rails,在主页上呈现不同的标题》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
RESTful Web Services Cookbook
Subbu Allamaraju / Yahoo Press / 2010-3-11 / USD 39.99
While the REST design philosophy has captured the imagination of web and enterprise developers alike, using this approach to develop real web services is no picnic. This cookbook includes more than 10......一起来看看 《RESTful Web Services Cookbook》 这本书的介绍吧!