回答編集履歴
1
コードの追加
answer
CHANGED
@@ -1,6 +1,25 @@
|
|
1
|
-
Rails側のパラメーター記述をネストさせました。
|
1
|
+
Rails側のパラメーター記述をネストさせました。それに伴い、JS側から送信する値も変更しました。
|
2
2
|
|
3
|
+
```js
|
4
|
+
update (context) {
|
5
|
+
const list = context.state.todos.list
|
6
|
+
const bookId = context.state.book.selectedBook.id
|
7
|
+
const content =
|
8
|
+
list.map((item) => {
|
9
|
+
return {
|
10
|
+
content: item.content,
|
11
|
+
status: false
|
12
|
+
}
|
13
|
+
})
|
14
|
+
this.$axios.$patch(url.POST_API + 'posts/' + bookId, {
|
15
|
+
post: {
|
16
|
+
post_items_attributes: content
|
17
|
+
}
|
18
|
+
})
|
19
|
+
}
|
3
20
|
```
|
21
|
+
|
22
|
+
```rb
|
4
23
|
private
|
5
24
|
def content_params
|
6
25
|
params.require(:post).permit(post_items_attributes:[:id, :content, :status])
|