Skip to content

Commit 60d72b5

Browse files
author
wenjieyeo
committed
Finish static pages
1 parent d6f63f1 commit 60d72b5

File tree

8 files changed

+54
-9
lines changed

8 files changed

+54
-9
lines changed

Diff for: app/controllers/static_pages_controller.rb

+6
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ def home
44

55
def help
66
end
7+
8+
def about
9+
end
10+
11+
def contact
12+
end
713
end

Diff for: app/views/layouts/application.html.erb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>HelloApp</title>
4+
<title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
55
<%= csrf_meta_tags %>
6-
7-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
6+
<%= stylesheet_link_tag 'application', media: 'all',
7+
'data-turbolinks-track': 'reload' %>
88
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
99
</head>
1010

1111
<body>
1212
<%= yield %>
1313
</body>
14-
</html>
14+
</html>

Diff for: app/views/static_pages/about.html.erb

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

Diff for: app/views/static_pages/contact.html.erb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% provide(:title, "Contact") %>
2+
<h1>Contact</h1>
3+
<p>
4+
Contact the Ruby on Rails Tutorial about the sample app at the
5+
<a href="http://www.railstutorial.org/contact">contact page</a>.
6+
</p>

Diff for: 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="http://www.railstutorial.org/help">Rails Tutorial help section</a>.
6+
To get help on this sample app, see the
7+
<a href="http://www.railstutorial.org/book"><em>Ruby on Rails Tutorial</em>
8+
book</a>.
9+
</p>

Diff for: 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="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
6+
sample application.
7+
</p>

Diff for: config/routes.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
Rails.application.routes.draw do
2+
root 'static_pages#home'
3+
24
get 'static_pages/home'
35

46
get 'static_pages/help'
57

8+
get 'static_pages/about'
9+
10+
get 'static_pages/contact'
11+
612
resources :microposts
713
resources :users
814
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
9-
root 'users#index'
1015
end

Diff for: test/controllers/static_pages_controller_test.rb

+5
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ class StaticPagesControllerTest < ActionDispatch::IntegrationTest
1111
assert_response :success
1212
end
1313

14+
test "should get about" do
15+
get static_pages_about_url
16+
assert_response :success
17+
end
18+
1419
end

0 commit comments

Comments
 (0)