質問編集履歴

3

誤コード修正

2018/06/08 22:50

投稿

zendendo
zendendo

スコア43

test CHANGED
File without changes
test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  でストロングパラメータ化して受け取れる(2という値だけ受け取れる)のですが、
42
42
 
43
- "buy_order_detail"=>{"quantity"=>"16"},の部分を下記のようにストロングパラメータ化して、find検索に使おうとすると
43
+ "buy_order_detail"=>{"quantity"=>"16"},の部分を下記のようにストロングパラメータ化して、
44
44
 
45
45
  **16という値だけが欲しいのに**、
46
46
 
@@ -52,7 +52,9 @@
52
52
 
53
53
  def confirm
54
54
 
55
+ #数量情報だけ欲しい
56
+
55
- @purchased_item = ItemStock.find(buy_order2_params)
57
+ @quantity = (buy_order2_params)
56
58
 
57
59
  end
58
60
 

2

状況が変わったので内容変更

2018/06/08 22:50

投稿

zendendo
zendendo

スコア43

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  {"utf8"=>"✓",
16
16
 
17
- "authenticity_token"=>"0625TR5D+dm4/dThdaMRjUzBMxrTc9OLACxbj/J2hKLQks3PchBZrYi3edFyiDnsYSvpAI58nrneG+jjA4yFZQ==",
17
+ "authenticity_token"=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
18
18
 
19
19
  "buy_order_detail"=>{"quantity"=>"16"},
20
20
 
@@ -26,25 +26,27 @@
26
26
 
27
27
 
28
28
 
29
- この内、"buy_order_detail"=>{"quantity"=>"16"},は、
29
+ この内、"item_stock_id"=>"2",は、
30
30
 
31
31
  ```ここに言語を入力
32
32
 
33
33
  def buy_order1_params
34
34
 
35
- params.require(:buy_order_detail).permit(:quantity)
35
+ params.require(:item_stock_id)
36
36
 
37
37
  end
38
38
 
39
39
  ```
40
40
 
41
- でストロングパラメータ化できるのですが、
41
+ でストロングパラメータ化して受け取れ(2という値だけ受け取れる)のですが、
42
42
 
43
- "item_stock_id"=>"2"の部分を下記のようにストロングパラメータ化して、検索に使おうとすると
43
+ "buy_order_detail"=>{"quantity"=>"16"},の部分を下記のようにストロングパラメータ化して、find検索に使おうとすると
44
44
 
45
- Couldn't find ItemStock with 'id'={"item_stock_id"=>"2"}というエラー発生てしまます。
45
+ **16という値だけしいのに**、
46
46
 
47
- (2という値だけ欲しいのに"item_stock_id"=>"といった余分な部分も入ってしまってる?)
47
+ {"quantity"=>"16"}という値がストロングパラメータに入ってしまいます。
48
+
49
+
48
50
 
49
51
  ```ここに言語を入力
50
52
 
@@ -60,7 +62,7 @@
60
62
 
61
63
  def buy_order2_params
62
64
 
63
- params.permit(:item_stock_id)
65
+ params.require(:buy_order_detail).permit(:quantity)
64
66
 
65
67
  end
66
68
 

1

追記

2018/06/08 22:39

投稿

zendendo
zendendo

スコア43

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  Couldn't find ItemStock with 'id'={"item_stock_id"=>"2"}というエラーが発生してしまいます。
46
46
 
47
- ("item_stock_id"=>"といった余分な情報が入ってしまっている?)
47
+ 2という値だけ欲しいのに"item_stock_id"=>"といった余分な部分も入ってしまっている?)
48
48
 
49
49
  ```ここに言語を入力
50
50