質問編集履歴
2
strong parameter
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,4 +17,11 @@
|
|
17
17
|
}
|
18
18
|
```
|
19
19
|
|
20
|
+
Strong Parameterはこちらです。
|
21
|
+
```ruby
|
22
|
+
def article_params
|
23
|
+
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])
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
20
27
|
よろしくお願いします!
|
1
変数一部修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
RSpecでテストしているのですが、書き方の分からない箇所があるのでお聞きします。
|
2
2
|
has_manyとnested_attributeで定義された2つのモデルが有り、データが以下のような形で送られてきます。
|
3
|
-
[:article][:article _categories]["0"][:category _id]
|
3
|
+
[:article][:article _categories]["0"][:category _id] = 40000
|
4
4
|
これを
|
5
|
-
let
|
5
|
+
letで表現するにはどう書いたら良いでしょうか?
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
let(:valid_attributes) {
|
9
|
+
{
|
10
|
+
status: "ready",
|
11
|
+
publish_datetime: "2017-04-16 19:51:03",
|
12
|
+
user_id: user.id,
|
13
|
+
update_user_id: user.id,
|
14
|
+
article_categories_attributes:[
|
15
|
+
category_id: ["40001", "40002"]
|
16
|
+
]
|
17
|
+
}
|
18
|
+
```
|
19
|
+
|
6
20
|
よろしくお願いします!
|