質問編集履歴
1
コード画像をマークダウンに変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,13 +22,69 @@
|
|
22
22
|
|
23
23
|
(1) /controllers/articles_controller.rb
|
24
24
|
|
25
|
+
```ruby
|
26
|
+
|
27
|
+
<div class="container">
|
28
|
+
|
25
|
-
|
29
|
+
<%= @articles.each do |article| %>
|
30
|
+
|
31
|
+
<div class="col-md-3">
|
32
|
+
|
33
|
+
<%= article.title %>
|
34
|
+
|
35
|
+
<%= article.created_at %>
|
36
|
+
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
</div>
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
|
26
46
|
|
27
47
|
|
28
48
|
|
29
49
|
(2) /views/articles/index.html.erb
|
30
50
|
|
51
|
+
```ruby
|
52
|
+
|
53
|
+
class ArticlesController < ApplicationController
|
54
|
+
|
55
|
+
def index
|
56
|
+
|
31
|
-
|
57
|
+
@articles = Article.order(created_at: :desc)
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
def show
|
64
|
+
|
65
|
+
@article = Article.find_by(id: params[:id])
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
def new
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
def edit
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
```
|
32
88
|
|
33
89
|
|
34
90
|
|