質問編集履歴

2

誤字の修正

2016/09/18 11:12

投稿

rendezvous_pc
rendezvous_pc

スコア12

test CHANGED
File without changes
test CHANGED
@@ -26,9 +26,11 @@
26
26
 
27
27
  実現したい処理としましては、
28
28
 
29
- > ①チェックされている項目では、INSERT時にplatform_typeの値挿入
29
+ > ①チェックされている項目では、INSERT時にplatform_typeの値挿入
30
30
 
31
- > チェックされていない項目ではDELETE
31
+ > チェックされていない項目ではDELETE
32
+
33
+
32
34
 
33
35
  となります。
34
36
 
@@ -38,7 +40,9 @@
38
40
 
39
41
  > ①チェックされている項目では、INSERT時にplatform_typeの値が空
40
42
 
41
- > チェックされていない項目ではplatform_typeの値が挿入され、DELETEされない
43
+ > チェックされていない項目ではplatform_typeの値が挿入され、DELETEされない
44
+
45
+
42
46
 
43
47
  といった状況です。
44
48
 

1

記述の変更

2016/09/18 11:12

投稿

rendezvous_pc
rendezvous_pc

スコア12

test CHANGED
File without changes
test CHANGED
@@ -1,16 +1,16 @@
1
1
  全く同じ内容のチェックボックス郡を画面上に2つ用意し、
2
2
 
3
- どちらもuser_platformsという中間テーブルにデータを挿入する処理を考えております。
3
+ どちらもuser_platformsという中間テーブルにデータを挿入する処理を考えております。
4
4
 
5
5
 
6
6
 
7
7
  1つ目のチェックボックス郡で選択された値は、
8
8
 
9
- type => "1"
9
+ platform_type => "1"
10
10
 
11
11
  2つ目のチェックボックス郡で選択された値は、
12
12
 
13
- type => "2"
13
+ platform_type => "2"
14
14
 
15
15
 
16
16
 
@@ -18,15 +18,37 @@
18
18
 
19
19
 
20
20
 
21
- 現在考えております方法ビューのname値変更し
21
+ 現在はビューにhiddenフォーム用意することで
22
22
 
23
- ポストされきた値登録前に変換するといった方法です。
23
+ platform_typeの値とし"1"と"2"送信するが出来てす。
24
24
 
25
25
 
26
26
 
27
- これよりも簡単に装できる方法などがございましたら
27
+ 現した処理としましては
28
28
 
29
+ > ①チェックされている項目では、INSERT時にplatform_typeの値が挿入
30
+
31
+ > チェックされていない項目ではDELETE
32
+
33
+ となります。
34
+
35
+
36
+
37
+ 現在は
38
+
39
+ > ①チェックされている項目では、INSERT時にplatform_typeの値が空
40
+
41
+ > チェックされていない項目ではplatform_typeの値が挿入され、DELETEされない
42
+
43
+ といった状況です。
44
+
45
+
46
+
47
+ こちらの解決策をご存じの方がいらっしゃいましたら、
48
+
29
- えていただけると幸いです。
49
+ いただけると幸いです。
50
+
51
+
30
52
 
31
53
 
32
54
 
@@ -36,7 +58,7 @@
36
58
 
37
59
  > platforms(id, name)
38
60
 
39
- > user_platforms(id, user_id, platform_id, type)
61
+ > user_platforms(id, user_id, platform_id, platform_type )
40
62
 
41
63
 
42
64
 
@@ -54,7 +76,7 @@
54
76
 
55
77
 
56
78
 
57
- params.require(:user).permit(:name, platform_ids: [])
79
+ params.require(:user).permit(:name, platform_ids: [], :user_platforms_attributes => [:platform_type])
58
80
 
59
81
  ```
60
82
 
@@ -146,6 +168,10 @@
146
168
 
147
169
  = f.collection_check_boxes :platform_ids, Platform.all, :id, :name
148
170
 
171
+ =f.fields_for :user_platforms do |upf1|
172
+
173
+ =upf1.hidden_field :platform_type, :value => "1"
174
+
149
175
  .form-group
150
176
 
151
177
  = f.label :platform_ids, "サブプラットフォーム", class: "control-label"
@@ -154,7 +180,9 @@
154
180
 
155
181
  = f.collection_check_boxes :platform_ids, Platform.all, :id, :name
156
182
 
183
+ =f.fields_for :user_platforms do |upf2|
157
184
 
185
+ =upf2.hidden_field :platform_type, :value => "1"
158
186
 
159
187
  = f.submit "送信する", class: "btn btn-success"
160
188