add static pages

This commit is contained in:
songtianlun 2024-12-29 17:22:48 +08:00
parent 5bd0c44c91
commit 7ee9afebe0
8 changed files with 46 additions and 0 deletions

View File

@ -1,4 +1,8 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern allow_browser versions: :modern
def hello
render html: "Hello World!"
end
end end

View File

@ -0,0 +1,10 @@
class StaticPagesController < ApplicationController
def home
end
def help
end
def about
end
end

View File

@ -0,0 +1,2 @@
module StaticPagesHelper
end

View File

@ -0,0 +1,2 @@
<h1>StaticPages#about</h1>
<p>Find me in app/views/static_pages/about.html.erb</p>

View File

@ -0,0 +1,2 @@
<h1>StaticPages#help</h1>
<p>Find me in app/views/static_pages/help.html.erb</p>

View File

@ -0,0 +1,2 @@
<h1>StaticPages#home</h1>
<p>Find me in app/views/static_pages/home.html.erb</p>

View File

@ -1,4 +1,9 @@
Rails.application.routes.draw do Rails.application.routes.draw do
get "static_pages/home"
get "static_pages/help"
get "static_pages/about"
root "application#hello"
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.

View File

@ -0,0 +1,19 @@
require "test_helper"
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get static_pages_home_url
assert_response :success
end
test "should get help" do
get static_pages_help_url
assert_response :success
end
test "Should get about" do
get static_pages_about_url
assert_response :success
end
end