質問編集履歴

1

追記

2017/03/28 22:21

投稿

yuta_tokyo
yuta_tokyo

スコア35

test CHANGED
File without changes
test CHANGED
@@ -15,3 +15,33 @@
15
15
 
16
16
 
17
17
  categoryモデルはscaffoldで自動生成しました。
18
+
19
+
20
+
21
+ ###updateアクションを追記します
22
+
23
+ ```
24
+
25
+ def update
26
+
27
+ respond_to do |format|
28
+
29
+ if @post.update(post_params)
30
+
31
+ format.html { redirect_to @post, notice: 'Post was successfully updated.' }
32
+
33
+ format.json { render :show, status: :ok, location: @post }
34
+
35
+ else
36
+
37
+ format.html { render :edit }
38
+
39
+ format.json { render json: @post.errors, status: :unprocessable_entity }
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ ```