リスト5.31のあと、今の状態を図5.10のようになるだろうとみてみると、こんなのがでてきました。
ん~~チュートリアル通りにしたのになんでかなあ。
Showing /home/ec2-user/environment/sample_app/app/views/layouts/application.html.erb where line #4 raised:と書いてありましたがよくわからなかったので、試しにhelper/applicationhelper.rb のフォルダを確認すると、
application_helper.rb
module ApplicationHelper #ページごとの完全なタイトルを返します。
def full_title(page_title = '') #コメント行(以下コメント一個ずつ上に)
base_title = "Ruby on Rails Tutorial Sample App" #メソッド定義とオプション引数
if page_title.empty? #変数への代入
base_title #論理値テスト
else #暗黙の戻り値
page_title + " | " + base_title
end
end
end
これもチュートリアル通りにやったのになぜ・・・?
結局 views/static_pages/about.html.erbを編集をしたらエラーが解決しました。
これを
views/static_pages/about.html.erb
<% provide(:title, "About") %>
<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>
こうした。
views/static_pages/about.html.erb
<% provide(:page_title, "About") %>
<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>
titleをpage_titleに変更しました。ここの名前がエラーだったのかな。
できたー!
railsチュートリアル通りにしたのですが、どこかで見逃していたのでしょうか・・・
まだまだルーティングなどに弱いです。
ちなみに今回初Qiitaでしたので、以下のコードの載せ方を参考にさせていただきました。
Qiita Markdown 書き方 まとめ