質問編集履歴
5
モデルの記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -145,3 +145,19 @@
|
|
145
145
|
|
146
146
|
|
147
147
|
```
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
**model**
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
class Piyo < ApplicationRecord
|
158
|
+
|
159
|
+
has_many :hoges, dependent: :destroy
|
160
|
+
|
161
|
+
has_many :fugas, dependent: :destroy
|
162
|
+
|
163
|
+
```
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
"authenticity_token"=>"F98xi8sKXsi7vZmlhtGZpTXpMU0DsDv4FexHYHzVRgXpbkoiJF5429GL1+IIPGZMIo
|
14
14
|
|
15
|
-
"hoge"=>{"0"=>{"title"=>"title1", "order"=>"1"}, "1"=>{"
|
15
|
+
"hoge"=>{"0"=>{"title"=>"title1", "order"=>"1"}, "1"=>{"title"=>"title2",
|
16
16
|
|
17
|
-
"order"=>"1"}}, "fuga"=>{"0"=>{"
|
17
|
+
"order"=>"1"}}, "fuga"=>{"0"=>{"title"=>"title1", "order"=>"1"}, "1"=>{"title"=>"title2",
|
18
18
|
|
19
19
|
"order"=>"1"}}
|
20
20
|
|
@@ -46,9 +46,9 @@
|
|
46
46
|
|
47
47
|
"authenticity_token"=>"F98xi8sKXsi7vZmlhtGZpTXpMU0DsDv4FexHYHzVRgXpbkoiJF5429GL1+IIPGZMIo
|
48
48
|
|
49
|
-
"hoge"=>{"0"=>{"title"=>"title1", "order"=>"1"}, "1"=>{"
|
49
|
+
"hoge"=>{"0"=>{"title"=>"title1", "order"=>"1"}, "1"=>{"title"=>"title2",
|
50
50
|
|
51
|
-
"order"=>"2"}}, "fuga"=>{"0"=>{"
|
51
|
+
"order"=>"2"}}, "fuga"=>{"0"=>{"title"=>"title1", "order"=>"1"}, "1"=>{"title"=>"title2",
|
52
52
|
|
53
53
|
"order"=>"2"}}
|
54
54
|
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
```
|
72
72
|
|
73
|
-
"hoge"=>{"1"=>{"title"=>"title1", "order"=>"1"}, "0"=>{"
|
73
|
+
"hoge"=>{"1"=>{"title"=>"title1", "order"=>"1"}, "0"=>{"title"=>"title2",
|
74
74
|
|
75
75
|
"order"=>"2"}}
|
76
76
|
|
@@ -136,9 +136,9 @@
|
|
136
136
|
|
137
137
|
def piyo_params
|
138
138
|
|
139
|
-
params.require(:piyo).permit(hoge: [:id, :order, :
|
139
|
+
params.require(:piyo).permit(hoge: [:id, :order, :title, :_destroy],
|
140
140
|
|
141
|
-
fuga: [:id, :order, :
|
141
|
+
fuga: [:id, :order, :title, :_destroy])
|
142
142
|
|
143
143
|
end
|
144
144
|
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -136,7 +136,7 @@
|
|
136
136
|
|
137
137
|
def piyo_params
|
138
138
|
|
139
|
-
params.require(:
|
139
|
+
params.require(:piyo).permit(hoge: [:id, :order, :name, :_destroy],
|
140
140
|
|
141
141
|
fuga: [:id, :order, :name, :_destroy])
|
142
142
|
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -132,4 +132,16 @@
|
|
132
132
|
|
133
133
|
|
134
134
|
|
135
|
+
private
|
136
|
+
|
137
|
+
def piyo_params
|
138
|
+
|
139
|
+
params.require(:recipe).permit(hoge: [:id, :order, :name, :_destroy],
|
140
|
+
|
141
|
+
fuga: [:id, :order, :name, :_destroy])
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
|
135
147
|
```
|
1
コントローラーの記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -87,3 +87,49 @@
|
|
87
87
|
|
88
88
|
|
89
89
|
どうかご教示お願い致します。
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
##追記
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
**controller**
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
def new
|
106
|
+
|
107
|
+
@piyo = Piyo.new
|
108
|
+
|
109
|
+
@hoge.hoge.build
|
110
|
+
|
111
|
+
@huga.huga.build
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
def create
|
118
|
+
|
119
|
+
@piyo = Piyo.new(piyo_params)
|
120
|
+
|
121
|
+
if @piyo.save
|
122
|
+
|
123
|
+
redirect_to piyos_path
|
124
|
+
|
125
|
+
else
|
126
|
+
|
127
|
+
render 'new'
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```
|