Skip to content

Commit 4e3f469

Browse files
committed
Finish static pages
1 parent 4724ff3 commit 4e3f469

File tree

9 files changed

+64
-8
lines changed

9 files changed

+64
-8
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@
3333

3434
# Ignore master key for decrypting credentials and more.
3535
/config/master.key
36+
37+
# Ignore db test files.
38+
db/test.*

app/controllers/static_pages_controller.rb

+3
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ def home
44

55
def help
66
end
7+
8+
def about
9+
end
710
end

app/views/layouts/application.html.erb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>SampleApp</title>
4+
<title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<meta charset="utf-8">
67
<%= csrf_meta_tags %>
78
<%= csp_meta_tag %>
89

app/views/static_pages/about.html.erb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<% provide(:title, "About") %>
2+
<h1>About</h1>
3+
<p>
4+
The <a href="https://www.railstutorial.org/"><em>Ruby on Rails
5+
Tutorial</em></a>, part of the
6+
<a href="https://www.learnenough.com/">Learn Enough</a> family of
7+
tutorials, is a
8+
<a href="https://www.railstutorial.org/book">book</a> and
9+
<a href="https://screencasts.railstutorial.org/">screencast series</a>
10+
to teach web development with
11+
<a href="https://rubyonrails.org/">Ruby on Rails</a>.
12+
This is the sample app for the tutorial.
13+
</p>

app/views/static_pages/help.html.erb

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
<h1>StaticPages#help</h1>
2-
<p>Find me in app/views/static_pages/help.html.erb</p>
1+
<% provide(:title, "Help") %>
2+
<h1>Help</h1>
3+
<p>
4+
Get help on the Ruby on Rails Tutorial at the
5+
<a href="https://www.railstutorial.org/help">Rails Tutorial Help page</a>.
6+
To get help on this sample app, see the
7+
<a href="https://www.railstutorial.org/book"><em>Ruby on Rails Tutorial</em>
8+
book</a>.
9+
</p>

app/views/static_pages/home.html.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
<h1>StaticPages#home</h1>
2-
<p>Find me in app/views/static_pages/home.html.erb</p>
1+
<% provide(:title, "Home") %>
2+
<h1>Sample App</h1>
3+
<p>
4+
This is the home page for the
5+
<a href="https://www.railstutorial.org/">Ruby on Rails Tutorial</a>
6+
sample application.
7+
</p>

config/routes.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Rails.application.routes.draw do
2-
get 'static_pages/home'
3-
get 'static_pages/help'
4-
root "application#hello"
2+
root "static_pages#home"
3+
get "static_pages/home"
4+
get "static_pages/help"
5+
get "static_pages/about"
56
end

db/schema.rb

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
require "test_helper"
22

33
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
4+
45
test "should get home" do
56
get static_pages_home_url
67
assert_response :success
8+
assert_select "title", "Home | Ruby on Rails Tutorial Sample App"
79
end
810

911
test "should get help" do
1012
get static_pages_help_url
1113
assert_response :success
14+
assert_select "title", "Help | Ruby on Rails Tutorial Sample App"
15+
end
16+
17+
test "should get about" do
18+
get static_pages_about_url
19+
assert_response :success
20+
assert_select "title", "About | Ruby on Rails Tutorial Sample App"
1221
end
1322
end

0 commit comments

Comments
 (0)