回答編集履歴
2
コメントはマークダウンできないようなので回答追記
answer
CHANGED
@@ -1,4 +1,29 @@
|
|
1
1
|
PUT送ればupdateされると思います
|
2
2
|
```
|
3
3
|
%= form_for(@poem, url: poems_path, html: { method: :put } do |f| %>
|
4
|
-
```
|
4
|
+
```
|
5
|
+
|
6
|
+
|
7
|
+
◆追記(ルーティングについて)
|
8
|
+
ルーティングを現状と変えないなら
|
9
|
+
|
10
|
+
```
|
11
|
+
resource :poems, only: [:edit, :update]
|
12
|
+
|
13
|
+
GET /poems/edit →今日のpoem編集
|
14
|
+
PUT /poems → 今日のpoem更新
|
15
|
+
GET /poems/edit?date=xxx → xxx日のpoem編集
|
16
|
+
```
|
17
|
+
|
18
|
+
※以下は個人的な見解です
|
19
|
+
ただし1日ごとに1つのpoemを作るならパラメータでdateを受け渡すよりも、
|
20
|
+
日付ごとの各poemにそれぞれURLがある方が良いと思います。
|
21
|
+
|
22
|
+
```
|
23
|
+
resources :poems, param:date, only: [:edit, :update]
|
24
|
+
|
25
|
+
GET /poems/xxx/edit → xxx日のpoem編集
|
26
|
+
PUT /poems/xxx → xxx日のpoem更新
|
27
|
+
```
|
28
|
+
|
29
|
+
xxxはparams[:date]で受けることが出来ます。
|
1
誤った捕捉説明を削除
answer
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
form_forから送られるリクエストはデフォルトPOSTなのでcreateにルーティングされます。
|
2
1
|
PUT送ればupdateされると思います
|
3
2
|
```
|
4
3
|
%= form_for(@poem, url: poems_path, html: { method: :put } do |f| %>
|