質問編集履歴

1

Controllerとviewの情報を追加しました。

2020/05/12 01:17

投稿

ken-
ken-

スコア3

test CHANGED
File without changes
test CHANGED
@@ -18,13 +18,95 @@
18
18
 
19
19
  ```
20
20
 
21
- #<Post:0x000000000(読み込みごとに数英ランダムで7文字表示される)>
21
+ #<Post:0x000000000dc132e0>
22
22
 
23
+ #<Post:0x000000000dc11490>
24
+
25
+ #<Post:0x000000000dc11350>
26
+
27
+ #<Post:0x000000000dc11210>
28
+
29
+ #<Post:0x000000000dc110d0>
30
+
31
+ #<Post:0x000000000dc10f90>
32
+
33
+ #<Post:0x000000000dc10e50>
34
+
23
- ×7個
35
+ ※後ろ七桁は読み込むごとに値が変わります。
24
36
 
25
37
 
26
38
 
27
39
  ```
40
+
41
+
42
+
43
+ ### Controller
44
+
45
+
46
+
47
+ ```
48
+
49
+ class PostsController < ApplicationController
50
+
51
+ def index
52
+
53
+ @posts = Post.all
54
+
55
+ end
56
+
57
+ end
58
+
59
+ ```
60
+
61
+
62
+
63
+ ###View
64
+
65
+ ```
66
+
67
+ <header>
68
+
69
+ <div class="header-logo">
70
+
71
+ <a href="/">TweetApp</a>
72
+
73
+ </div>
74
+
75
+ <ul class="header-menus">
76
+
77
+ <li>
78
+
79
+ <a href="/about">TweetAppとは</a>
80
+
81
+ </li>
82
+
83
+ </ul>
84
+
85
+ </header>
86
+
87
+
88
+
89
+ <div class="main posts-index">
90
+
91
+ <div class="container">
92
+
93
+ <% @posts.each do |post| %>
94
+
95
+ <div class="posts-index-item">
96
+
97
+ <%= post %>
98
+
99
+ </div>
100
+
101
+ <% end %>
102
+
103
+ </div>
104
+
105
+ </div>
106
+
107
+ ```
108
+
109
+
28
110
 
29
111
 
30
112