Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sample_app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Hoang Mai Phuong
sample_app
Commits
42348eae
Commit
42348eae
authored
Jun 03, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish static pages
parent
3fdebb09
Pipeline
#1228
failed with stages
in 0 seconds
Changes
8
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
22 deletions
+33
-22
app/controllers/application_controller.rb
+0
-3
app/views/layouts/application.html.erb
+1
-1
app/views/static_pages/about.html.erb
+1
-0
app/views/static_pages/help.html.erb
+10
-2
app/views/static_pages/home.html.erb
+1
-9
app/views/static_pages/index.html.erb
+11
-3
config/routes.rb
+1
-1
test/controllers/static_pages_controller_test.rb
+8
-3
No files found.
app/controllers/application_controller.rb
View file @
42348eae
class
ApplicationController
<
ActionController
::
Base
class
ApplicationController
<
ActionController
::
Base
def
hello
render
html:
"hello, world!"
end
end
end
layout_file
→
app/views/layouts/application.html.erb
View file @
42348eae
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>
Sample
App
</title>
<title>
<%=
yield
(
:title
)
%>
| Ruby on Rails Tutorial Sample
App
</title>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1"
>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1"
>
<%=
csrf_meta_tags
%>
<%=
csrf_meta_tags
%>
<%=
csp_meta_tag
%>
<%=
csp_meta_tag
%>
...
...
app/views/static_pages/about.html.erb
View file @
42348eae
<%
provide
(
:title
,
"About"
)
%>
<h1>
About
</h1>
<h1>
About
</h1>
<p>
<p>
The
<a
href=
"https://www.railstutorial.org/"
><em>
Ruby on Rails
The
<a
href=
"https://www.railstutorial.org/"
><em>
Ruby on Rails
...
...
app/views/static_pages/help.html.erb
View file @
42348eae
<h1>
StaticPages#help
</h1>
<%
provide
(
:title
,
"Help"
)
%>
<p>
Find me in app/views/static_pages/help.html.erb
</p>
<h1>
Help
</h1>
<p>
Get help on the Ruby on Rails Tutorial at the
<a
href=
"https://www.railstutorial.org/help"
>
Rails Tutorial help
section
</a>
.
To get help on this sample app, see the
<a
href=
"https://www.railstutorial.org/book"
><em>
Ruby on Rails
Tutorial
</em>
book
</a>
.
</p>
app/views/static_pages/home.html.erb
View file @
42348eae
<!DOCTYPE html>
<%
provide
(
:title
,
"Home"
)
%>
<html>
<head>
<title>
Home | Ruby on Rails Tutorial Sample App
</title>
</head>
<body>
<h1>
Sample App
</h1>
<h1>
Sample App
</h1>
<p>
<p>
This is the home page for the
This is the home page for the
<a
href=
"https://www.railstutorial.org/"
>
Ruby on Rails Tutorial
</a>
<a
href=
"https://www.railstutorial.org/"
>
Ruby on Rails Tutorial
</a>
sample application.
sample application.
</p>
</p>
</body>
</html>
\ No newline at end of file
app/views/static_pages/index.html.erb
View file @
42348eae
<h1>
StaticPages
</h1>
<%
provide
(
:title
,
"Page Title"
)
%>
<p>
Find me in app/views/static_pages/home.html.erb
</p>
<!DOCTYPE html>
\ No newline at end of file
<html>
<head>
<title>
<%=
yield
(
:title
)
%>
| Ruby on Rails Tutorial Sample App
</title>
</head>
<body>
Contents
</body>
</html>
\ No newline at end of file
config/routes.rb
View file @
42348eae
...
@@ -7,7 +7,7 @@ Rails.application.routes.draw do
...
@@ -7,7 +7,7 @@ Rails.application.routes.draw do
#get 'static_pages/home'
#get 'static_pages/home'
#get 'static_pages/help'
#get 'static_pages/help'
#get 'static_pages/about'
#get 'static_pages/about'
root
'
application#hello
'
root
'
static_pages#home
'
get
'static_pages'
,
to:
'static_pages#index'
get
'static_pages'
,
to:
'static_pages#index'
end
end
test/controllers/static_pages_controller_test.rb
View file @
42348eae
require
"test_helper"
require
"test_helper"
class
StaticPagesControllerTest
<
ActionDispatch
::
IntegrationTest
class
StaticPagesControllerTest
<
ActionDispatch
::
IntegrationTest
def
setup
@base_title
=
"Ruby on Rails Tutorial Sample App"
end
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 |
Ruby on Rails Tutorial Sample App
"
assert_select
"title"
,
"Home |
#{
@base_title
}
"
end
end
test
"should get help"
do
test
"should get help"
do
get
static_pages_help_url
get
static_pages_help_url
assert_response
:success
assert_response
:success
assert_select
"title"
,
"Help |
Ruby on Rails Tutorial Sample App
"
assert_select
"title"
,
"Help |
#{
@base_title
}
"
end
end
test
"should get about"
do
test
"should get about"
do
get
static_pages_about_url
get
static_pages_about_url
assert_response
:success
assert_response
:success
assert_select
"title"
,
"About |
Ruby on Rails Tutorial Sample App
"
assert_select
"title"
,
"About |
#{
@base_title
}
"
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment