我有設置瀏覽器和頁面本身的標題的方法。在我的設計頁面上,我想設置這兩個方法,但不知道如何。爲Devise頁面設置瀏覽器和頁面標題?
我的代碼:
傭工/ application_helper
def title # for entire application
base_title = "Testing"
if @title.nil?
base_title
else
"#{base_title} - #{@title}"
end
end
def page_title # for page header partial
"#{@page_title}"
end
的意見/佈局/應用
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= csrf_meta_tag %>
<%= favicon_link_tag %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
</head>
<body>
<div id="container">
<%= render "shared/page_header" %>
<%= render "shared/flash_message" %>
<%= yield %>
</div>
</body>
</html>
的意見/共享/ _page_header
<% unless @page_title.blank? %>
<div id="page-header">
<span><%= @page_title %></span>
</div>
<% end %>
現在我有一個RegistrationsController來覆蓋功能,只要我需要,但因爲它繼承了DeviseController,我不認爲它可以得到應用程序幫助?我也嘗試將這個相同的代碼放入註冊助手中,但那也不起作用。我該怎麼辦?
'默認DeviseController'延伸'ApplicationController'。 ** [來源](https://github.com/plataformatec/devise/blob/master/lib/devise.rb#L200)** – deefour 2012-08-11 17:58:02