質問編集履歴

1

form_withに変更。

2021/07/15 22:56

投稿

yu.yu.yu
yu.yu.yu

スコア0

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,11 @@
10
10
 
11
11
  ```
12
12
 
13
- undefined method `permit' for "male":String
13
+ Parameters: {"authenticity_token"=>"OB1cWXcSMwdS/I3hL67MIym8WYKVpCrPcDm3x0pbh8Ii1W3LJt9wna8V9pplxzK7d43SXTCtR/3C+DsKSR+JUw==", "income"=>{"income"=>"uber"}, "price"=>"11111", "commit"=>"Create Income"}
14
+
15
+ Unpermitted parameter: :income
16
+
17
+ ターミナルにて、エラー出てて保存できない状態です。
14
18
 
15
19
  ```
16
20
 
@@ -22,33 +26,53 @@
22
26
 
23
27
  _form.html.erb
24
28
 
29
+
30
+
25
31
  <div class='type'>
26
32
 
27
33
  <div class='type-contents'>
28
34
 
29
- <label><input type="radio" name="income" value="male">ウーバーイーツ</label>
35
+ <%= form_with(model: @income, local: true) do |form| %>
30
36
 
31
- <label><input type="radio" name="income" value="male">食費</label>
37
+ <%= form.radio_button :income, :uber %>
32
38
 
33
- <label><input type="radio" name="income" value="male">日用品</label>
39
+ <%= form.label :income, "ウーバーイーツ", {value: :uber, style: "display: inline-block;"} %>
34
40
 
35
- <label><input type="radio" name="income" value="male">交通費</label><br />
41
+ <%= form.radio_button :income, :uber %>
36
42
 
37
- </div>
43
+ <%= form.label :income, "食費", {value: :food, style: "display: inline-block;"} %>
38
44
 
39
- <div class='type-contents'>
45
+ <%= form.radio_button :income, :food %>
40
46
 
41
- <label><input type="radio" name="income" value="male">積み立て費</label>
47
+ <%= form.label :income, "日用品", {value: :male, style: "display: inline-block;"} %>
42
48
 
43
- <label><input type="radio" name="income" value="male">クレジットカード</label>
49
+ <%= form.radio_button :income, :female %>
44
50
 
45
- <label><input type="radio" name="income" value="male">ファッション</label>
51
+ <%= form.label :income, "交通費", {value: :female, style: "display: inline-block;"} %><br />
46
52
 
47
- <label><input type="radio" name="income" value="male">その他</label><br />
53
+ <%= form.radio_button :income, :male %>
48
54
 
49
- </div>
55
+ <%= form.label :income, "積み立て費", {value: :male, style: "display: inline-block;"} %>
50
56
 
57
+ <%= form.radio_button :income, :female %>
58
+
59
+ <%= form.label :income, "クレジットカード", {value: :female, style: "display: inline-block;"} %>
60
+
61
+ <%= form.radio_button :income, :male %>
62
+
63
+ <%= form.label :income, "ファッション", {value: :male, style: "display: inline-block;"} %>
64
+
65
+ <%= form.radio_button :income, :female %>
66
+
67
+ <%= form.label :income, "その他", {value: :female, style: "display: inline-block;"} %><br />
68
+
51
- <input type="text" name="name" id="name" placeholder="金額"><br />
69
+ <input type="text" name="price" id="price" placeholder="金額"><br />
70
+
71
+
72
+
73
+ <%= form.submit %>
74
+
75
+ <% end %>
52
76
 
53
77
 
54
78