LoginSignup
0
0

More than 5 years have passed since last update.

動的なページの作成

Posted at

以下のページを参照してHomeページを作成しておく。
https://qiita.com/classe729/items/a7c3bbafb58d421bd586

Aboutページの動作を追加する。
まずは以下の通りになるよう修正する。

app/controllers/static_pages_controller.rb
class StaticPagesController < ApplicationController

  def home
  end

  def help
  end

  def about
  end
end

Aboutページの転送先を追加する。

app/views/static_pages/about.html.erb
<h1>About</h1>
<p>
  <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
  is a <a href="https://railstutorial.jp/#ebook">book</a> and
  <a href="https://railstutorial.jp/#screencast">screencast</a>
  to teach web development with
  <a href="http://rubyonrails.org/">Ruby on Rails</a>.
  This is the sample application for the tutorial.
</p>

http://XXX.XXX.XXX.XXX:3000/static_pages/about
にアクセスすると以下のようなページが出力される。

image.png

次いでcontact pageも作成する。

app/views/static_pages/contact.html.erb
<% provide(:title, "Contact") %>
<h1>Contact</h1>
<p>
  Contact the Ruby on Rails Tutorial about the sample app at the
  <a href="http://www.railstutorial.org/#contact">contact page</a>.
</p>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0