我想在new.html.erb
頁面中使用標題Ruby on Rails Tutorial Sample App | Foo's
。我的佈局:HTML編碼/使用Rails提供的功能退出
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
</div>
</body>
我new.html.erb
:
<% provide(:title, "Foo's") %>
<h1>Sign up</h1>
<p>Find me in app/views/users/new.html.erb</p>
但是我的標題是錯誤的:
我該怎麼辦呢?
-
Full_title
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
什麼是'full_title'? – coreyward
我編輯了full_title – Pierre
我有一個編碼錯誤!查看描述 – Pierre