質問編集履歴
2
strong parameter
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,4 +36,18 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
+
Strong Parameterはこちらです。
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
|
43
|
+
def article_params
|
44
|
+
|
45
|
+
params.require(:article).permit(:id, :current_version , :publish_version, :file, :status, :user_id , :update_user_id, :publish_at, :publish_until, article_categories_attributes: [:article_id, {:category_id => []}], article_tags_attributes: [:article_id, {:tag_id => []}], article_histories_attributes:[:id, :article_id, :version, :title, :content, :comment], articles_article_series_attributes:[:article_id, :series_id, :num])
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
|
52
|
+
|
39
53
|
よろしくお願いします!
|
1
変数一部修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,10 +2,38 @@
|
|
2
2
|
|
3
3
|
has_manyとnested_attributeで定義された2つのモデルが有り、データが以下のような形で送られてきます。
|
4
4
|
|
5
|
-
[:article][:article _categories]["0"][:category _id]
|
5
|
+
[:article][:article _categories]["0"][:category _id] = 40000
|
6
6
|
|
7
7
|
これを
|
8
8
|
|
9
|
-
let
|
9
|
+
letで表現するにはどう書いたら良いでしょうか?
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
|
15
|
+
let(:valid_attributes) {
|
16
|
+
|
17
|
+
{
|
18
|
+
|
19
|
+
status: "ready",
|
20
|
+
|
21
|
+
publish_datetime: "2017-04-16 19:51:03",
|
22
|
+
|
23
|
+
user_id: user.id,
|
24
|
+
|
25
|
+
update_user_id: user.id,
|
26
|
+
|
27
|
+
article_categories_attributes:[
|
28
|
+
|
29
|
+
category_id: ["40001", "40002"]
|
30
|
+
|
31
|
+
]
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
|
10
38
|
|
11
39
|
よろしくお願いします!
|