Skip to content

Commit c2e666b

Browse files
committed
Finish static pages
1 parent c803c78 commit c2e666b

File tree

9 files changed

+72
-14
lines changed

9 files changed

+72
-14
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232

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

app/controllers/static_pages_controller.rb

Lines changed: 3 additions & 0 deletions
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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title><%= content_for(:title) || "Sample App" %></title>
3+
4+
<head>
5+
<title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
56
<meta name="viewport" content="width=device-width,initial-scale=1">
67
<meta name="apple-mobile-web-app-capable" content="yes">
78
<meta name="mobile-web-app-capable" content="yes">
@@ -19,9 +20,10 @@
1920

2021
<%# Includes all stylesheet files in app/assets/stylesheets %>
2122
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
22-
</head>
23+
</head>
2324

24-
<body>
25+
<body>
2526
<%= yield %>
26-
</body>
27-
</html>
27+
</body>
28+
29+
</html>
Lines changed: 13 additions & 0 deletions
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>
Lines changed: 9 additions & 2 deletions
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>
Lines changed: 7 additions & 2 deletions
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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Rails.application.routes.draw do
2+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
23
get "static_pages/home"
34
get "static_pages/help"
4-
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
5-
5+
get "static_pages/about"
6+
root "application#hello"
67
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
78
# Can be used by load balancers and uptime monitors to verify that the app is live.
89
get "up" => "rails/health#show", as: :rails_health_check
@@ -12,5 +13,5 @@
1213
# get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
1314

1415
# Defines the root path route ("/")
15-
root "application#hello"
16+
# root "posts#index"
1617
end

db/schema.rb

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

33
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
4+
def setup
5+
@base_title = "Ruby on Rails Tutorial Sample App"
6+
end
7+
48
test "should get home" do
59
get static_pages_home_url
610
assert_response :success
11+
assert_select "title", "Home | #{@base_title}"
712
end
8-
913
test "should get help" do
1014
get static_pages_help_url
1115
assert_response :success
16+
assert_select "title", "Help | #{@base_title}"
17+
end
18+
test "should get about" do
19+
get static_pages_about_url
20+
assert_response :success
21+
assert_select "title", "About | #{@base_title}"
1222
end
1323
end

0 commit comments

Comments
 (0)