質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,9 +47,63 @@
|
|
47
47
|
```
|
48
48
|
|
49
49
|
```
|
50
|
+
posts/controller
|
50
51
|
|
52
|
+
def edit
|
53
|
+
@post = Post.find(params[:id])
|
54
|
+
end
|
55
|
+
|
56
|
+
def update
|
57
|
+
post = Post.find(params[:id])
|
58
|
+
post.update(post_params)
|
59
|
+
redirect_to post_path(post.id)
|
60
|
+
end
|
51
61
|
```
|
52
62
|
```
|
63
|
+
view/edit
|
64
|
+
|
65
|
+
<div class="post">
|
66
|
+
<h1>編集</h1>
|
67
|
+
<div class="post-detail">
|
68
|
+
<%= form_with model: @post, url: '/posts', local:true do |f| %>
|
69
|
+
|
70
|
+
<h4>タイトル</h4>
|
71
|
+
<%= f.text_field :title %>
|
72
|
+
<h4>あらすじ</h4>
|
73
|
+
<%= f.text_area :summary %>
|
74
|
+
<h4>見どころ</h4>
|
75
|
+
<%= f.text_area :highlight %>
|
76
|
+
<h4>ハッシュタグ入力欄</h4>
|
77
|
+
<%= f.text_area :hashbody, size:"55x3" %>
|
78
|
+
|
79
|
+
|
80
|
+
<h4><p><%= f.label :画像 %></p></h4>
|
81
|
+
<p><%= f.file_field :image %></p>
|
82
|
+
|
83
|
+
|
84
|
+
<div class="check_box">
|
85
|
+
<h4>ジャンル</h4>
|
86
|
+
<%= f.collection_check_boxes(:tag_ids, Tag.all, :id, :name) do |tag| %>
|
87
|
+
<div>
|
88
|
+
<%= tag.label do %>
|
89
|
+
<%= tag.check_box %>
|
90
|
+
<%= tag.text %>
|
91
|
+
<% end %>
|
92
|
+
</div>
|
93
|
+
<% end %>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<%= f.submit '保存', class: "btn" %>
|
99
|
+
|
100
|
+
<% end %>
|
101
|
+
|
102
|
+
view/update
|
103
|
+
|
104
|
+
</div>
|
105
|
+
<h1>Posts#update</h1>
|
106
|
+
<p>Find me in app/views/posts/update.html.erb</p>
|
53
107
|
|
54
108
|
```
|
55
109
|
|