Commit 459d819b by Quang Vinh Nguyen

Add full_title helper

parent 3316f08d
# some comment
module ApplicationHelper module ApplicationHelper
# Return the full title on per-page basis.
def full_title(page_title = '')
base_title = 'Ruby on Rails Tutorial Sample App'
if page_title.empty?
base_title
else
page_title + ' | ' + base_title
end
end
end end
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title><%=yield(:title) %> | Ruby on Rails Tutorial Sample App</title> <title><%= full_title(yield(:title)) %></title>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
......
<% provide(:title, "Home") %> <%# provide(:title, "Home") %>
<body> <body>
<h1>Sample App</h1> <h1>Sample App</h1>
......
...@@ -13,7 +13,8 @@ class StaticPagesControllerTest < ActionDispatch::IntegrationTest ...@@ -13,7 +13,8 @@ class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do test "should get home" do
get static_pages_home_url get static_pages_home_url
assert_response :success assert_response :success
assert_select "title", "Home | #{@base_title}" # assert_select "title", "Home | #{@base_title}"
assert_select "title", "Ruby on Rails Tutorial Sample App"
end end
test "should get help" do test "should get help" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment