質問編集履歴
6
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
belongs_to :Category
|
55
|
+
belongs_to :Category
|
56
56
|
|
57
57
|
|
58
58
|
|
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
モデル名:GyomuDatum
|
16
16
|
|
17
|
-
|ID|
|
17
|
+
|ID|category_id※外部キー|
|
18
18
|
|
19
19
|
|:--|:--:|
|
20
20
|
|
4
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
モデル名:Category
|
29
|
+
モデル名:Category
|
30
30
|
|
31
31
|
|
32
32
|
|
@@ -64,11 +64,11 @@
|
|
64
64
|
|
65
65
|
|
66
66
|
|
67
|
-
category
|
67
|
+
category.rb
|
68
68
|
|
69
69
|
```Ruby
|
70
70
|
|
71
|
-
class Category
|
71
|
+
class Category < ActiveRecord::Base
|
72
72
|
|
73
73
|
|
74
74
|
|
3
ソースを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,7 +80,189 @@
|
|
80
80
|
|
81
81
|
```
|
82
82
|
|
83
|
-
|
83
|
+
index.html.erb
|
84
|
+
|
85
|
+
```Ruby
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<p class="rei1">データ一覧</p>
|
90
|
+
|
91
|
+
<br>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<!-- 権限によってデータ一覧の項目値を変更 -->
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<section>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<table class="type06">
|
104
|
+
|
105
|
+
<thead>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<% if session[:authority] == "1" %>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<tr>
|
114
|
+
|
115
|
+
<th>管理ID</th>
|
116
|
+
|
117
|
+
<th>カテゴリ</th>
|
118
|
+
|
119
|
+
<th>発行会社</th>
|
120
|
+
|
121
|
+
<th>IPアドレス</th>
|
122
|
+
|
123
|
+
<th>対象サーバ</th>
|
124
|
+
|
125
|
+
<th>有効期限の開始日</th>
|
126
|
+
|
127
|
+
<th>有効期限の終了日</th>
|
128
|
+
|
129
|
+
<th>コメント</th>
|
130
|
+
|
131
|
+
<th>操作</th>
|
132
|
+
|
133
|
+
</tr>
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
</thead>
|
138
|
+
|
139
|
+
<tbody>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<% @items.each do |item| %>
|
144
|
+
|
145
|
+
<tr>
|
146
|
+
|
147
|
+
<td><%= item.manage_id %></td>
|
148
|
+
|
149
|
+
<td><%= item.category_id %></td>
|
150
|
+
|
151
|
+
<td><%= item.publish_corporation %></td>
|
152
|
+
|
153
|
+
<td><%= item.ip_address %></td>
|
154
|
+
|
155
|
+
<td><%= item.target_server %></td>
|
156
|
+
|
157
|
+
<td><%= item.start_date %></td>
|
158
|
+
|
159
|
+
<td><%= item.end_date %></td>
|
160
|
+
|
161
|
+
<td><%= item.comment %></td>
|
162
|
+
|
163
|
+
<td>
|
164
|
+
|
165
|
+
<%= link_to '[Edit]', edit_item_path(item), class: 'command' %>
|
166
|
+
|
167
|
+
<%= link_to '[Delete]',
|
168
|
+
|
169
|
+
item_path(item),
|
170
|
+
|
171
|
+
method: :delete,
|
172
|
+
|
173
|
+
class: 'command',
|
174
|
+
|
175
|
+
data: { confirm: 'データ削除しますか?' } %>
|
176
|
+
|
177
|
+
</td>
|
178
|
+
|
179
|
+
</tr>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
<% end %>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<% elsif session[:authority] == "2" %>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<tr>
|
194
|
+
|
195
|
+
<th>管理ID</th>
|
196
|
+
|
197
|
+
<th>カテゴリ</th>
|
198
|
+
|
199
|
+
<th>発行会社</th>
|
200
|
+
|
201
|
+
<th>IPアドレス</th>
|
202
|
+
|
203
|
+
<th>対象サーバ</th>
|
204
|
+
|
205
|
+
<th>有効期限の開始日</th>
|
206
|
+
|
207
|
+
<th>有効期限の終了日</th>
|
208
|
+
|
209
|
+
<th>コメント</th>
|
210
|
+
|
211
|
+
</tr>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<% @items.each do |item| %>
|
216
|
+
|
217
|
+
<tr>
|
218
|
+
|
219
|
+
<td><%= item.manage_id %></td>
|
220
|
+
|
221
|
+
<td><%= item.category_id %></td>
|
222
|
+
|
223
|
+
<td><%= item.publish_corporation %></td>
|
224
|
+
|
225
|
+
<td><%= item.ip_address %></td>
|
226
|
+
|
227
|
+
<td><%= item.target_server %></td>
|
228
|
+
|
229
|
+
<td><%= item.start_date %></td>
|
230
|
+
|
231
|
+
<td><%= item.end_date %></td>
|
232
|
+
|
233
|
+
<td><%= item.comment %></td>
|
234
|
+
|
235
|
+
</tr>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
<% end %>
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
<% else %>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<!-- データ一覧を表示しない -->
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
<% end %>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
</tbody>
|
256
|
+
|
257
|
+
</table>
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
</section>
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
```
|
84
266
|
|
85
267
|
|
86
268
|
|
2
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
モデル名:GyomuDatum
|
16
16
|
|
17
|
-
|ID|name_id|
|
17
|
+
|ID|name_id※外部キー|
|
18
18
|
|
19
19
|
|:--|:--:|
|
20
20
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
|ID|name|
|
33
|
+
|ID※主キー|name|
|
34
34
|
|
35
35
|
|:--|:--:|
|
36
36
|
|
1
文章変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
下記の二つのDBを連携させる方法について教えてください。
|
6
6
|
|
7
|
-
実現したいことはnameの情報はCategoryDatumに格納されていて、GyomuDatum側では対応するIDを格納し、viewで表示させたいです。
|
7
|
+
実現したいことはnameの情報はCategoryDatumに格納されていて、GyomuDatum側では対応するIDを格納し、viewでnameカラムの情報を表示させたいです。
|
8
8
|
|
9
9
|
モデルファイルに記載する内容は下記に記載していますが、それ以降にどのような設定をすれば、良いかが分からず困っています。
|
10
10
|
|
@@ -14,43 +14,31 @@
|
|
14
14
|
|
15
15
|
モデル名:GyomuDatum
|
16
16
|
|
17
|
-
ID
|
17
|
+
|ID|name_id|
|
18
18
|
|
19
|
-
|
19
|
+
|:--|:--:|
|
20
|
+
|
21
|
+
|1|1|
|
22
|
+
|
23
|
+
|2|2|
|
20
24
|
|
21
25
|
|
22
|
-
|
23
|
-
モデルファイル記載内容↓
|
24
|
-
|
25
|
-
belongs_to :categorydata
|
26
26
|
|
27
27
|
|
28
28
|
|
29
29
|
モデル名:CategoryDatum
|
30
30
|
|
31
|
-
ID:1 , name:ichiro
|
32
|
-
|
33
|
-
ID:2 , name:taro
|
34
31
|
|
35
32
|
|
33
|
+
|ID|name|
|
36
34
|
|
37
|
-
|
35
|
+
|:--|:--:|
|
38
36
|
|
39
|
-
h
|
37
|
+
|1|ichiro|
|
38
|
+
|
39
|
+
|2|taro|
|
40
40
|
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
### 発生している問題・エラーメッセージ
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
```
|
50
|
-
|
51
|
-
エラーメッセージ
|
52
|
-
|
53
|
-
```
|
54
42
|
|
55
43
|
|
56
44
|
|