![](https://prog-8.com/assets/icn_clock-e21464eeb26e89607431b51222dfc219ac4341c94a81db0219f6748b97121650.png)
2h10m Progate Ruby on Rails 5 Ⅱ(Part3)はコチラから
いよいよⅢに突入します。
大きな不安を抱えていますが、がんばります。
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_2.png)
自動生成されるカラム
$ rails console
いつものようにコンソールを起動して
引数を(content: “Rails勉強中!”)とします。忘れずにsave。
post = Post.new(content: "Rails勉強中!") post.save
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_3-1.png)
データベースが更新されました。
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_4.png)
find_byメソッドで投稿を取得しよう
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_5.png)
//メソッドを用いてidが「3」の投稿データを取得 post = Post.find_by(id: 3)
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_6.png)
//投稿内容を取得 post.content
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_7.png)
//投稿時刻を取得 post.created_at
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_8.png)
投稿詳細ページを作成しよう
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_9.png)
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_10.png)
//routes.rbにルーティングを追加 get "posts/:id" => "posts#show"
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_11.png)
//posts_controller.rbにルーティングで指定したshowアクションを作成 def show end
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_12.png)
//投稿詳細ページ用のビューを作成 //show.html.erbファイルを作成 <div class="main posts-show"> <div class="container"> <div class="posts-show-item"> <p>投稿詳細画面です</p> </div> </div> </div>
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_13.png)
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_14.png)
詳細画面が表示されていることを確認。
![](https://goohayami.com/wp-content/uploads/2022/03/ra3_15.png)
Part2は変数paramsについてです。
理解がなかなか追いついていきませんが、がんばります!