Skip to content

Commit 7e482f4

Browse files
committed
Finish static pages
1 parent dc93a57 commit 7e482f4

File tree

8 files changed

+65
-8
lines changed

8 files changed

+65
-8
lines changed

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>SampleApp</title>
4+
<title><%= yield(:title)%> | Ruby on Rails Tutorial Sample App</title>
55
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
66
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
77
<%= csrf_meta_tags %>

app/views/static_pages/about.html.erb

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

app/views/static_pages/help.html.erb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
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
6+
section</a>.
7+
To get help on this sample app, see the
8+
<a href="http://www.railstutorial.org/book"><em>Ruby on Rails
9+
Tutorial</em> book</a>.
10+
</p>

app/views/static_pages/home.html.erb

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

config/routes.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Rails.application.routes.draw do
2-
get 'static_pages/home'
3-
2+
root 'static_pages#home'
43
get 'static_pages/help'
4+
get 'static_pages/about'
5+
56

67
# The priority is based upon order of creation: first created -> highest priority.
78
# See how all your routes lay out with "rake routes".
89

910
# You can have the root of your site routed with "root"
10-
root 'application#hello'
11+
#root 'application#hello'
1112

1213
# Example of regular route:
1314
# get 'products/:id' => 'catalog#view'

db/schema.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# encoding: UTF-8
2+
# This file is auto-generated from the current state of the database. Instead
3+
# of editing this file, please use the migrations feature of Active Record to
4+
# incrementally modify your database, and then regenerate this schema definition.
5+
#
6+
# Note that this schema.rb definition is the authoritative source for your
7+
# database schema. If you need to create the application database on another
8+
# system, you should be using db:schema:load, not running all the migrations
9+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
10+
# you'll amass, the slower it'll run and the greater likelihood for issues).
11+
#
12+
# It's strongly recommended that you check this file into your version control system.
13+
14+
ActiveRecord::Schema.define(version: 0) do
15+
16+
end

test/controllers/static_pages_controller_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@ class StaticPagesControllerTest < ActionController::TestCase
44
test "should get home" do
55
get :home
66
assert_response :success
7+
assert_select "title", "Home | Ruby on Rails Tutorial Sample App"
8+
end
9+
test "should get about" do
10+
get :about
11+
assert_response :success
12+
assert_select "title", "About | Ruby on Rails Tutorial Sample App"
713
end
814

915
test "should get help" do
1016
get :help
1117
assert_response :success
18+
assert_select "title", "Help | Ruby on Rails Tutorial Sample App"
1219
end
20+
#test "shout get about" do
21+
# get :static_pages_help_url
22+
# assert_response :success
23+
#end
1324

1425
end

0 commit comments

Comments
 (0)