質問編集履歴
1
内容を変更しました
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Ruby on Railsで
|
1
|
+
Ruby on Railsでリアルタイムなランキングを作る方法
|
body
CHANGED
@@ -1,71 +1,27 @@
|
|
1
|
-
---
|
2
1
|
###前提・実現したいこと
|
3
|
-
皆さま、こんちわ。Ruby初心者です。
|
4
|
-
システム会社の開発環境や使用している技術を閲覧できるサービスを作ってます。
|
5
|
-
今回、企業ごとに多く使われている技術部門を1か月毎に代わる
|
6
|
-
|
2
|
+
ご閲覧ありがとうございます。
|
7
|
-
|
3
|
+
ユーザーが今できるプログラミング言語を登録したとき
|
4
|
+
結果として、一番人気のプログラミング言語は何かというランキングページを作りたいのですが、
|
8
|
-
|
5
|
+
どうしたらよいでしょうか?
|
9
|
-
2.PHP
|
10
|
-
3.C#
|
11
6
|
|
12
|
-
例)今月(11月)プログラミング部門
|
13
|
-
1.Ruby
|
14
|
-
2.C#
|
15
|
-
3.Kotlin
|
16
7
|
|
17
|
-
###発生している問題
|
18
8
|
|
19
|
-
```
|
20
|
-
それでルビーオンレイルズでこのようなものを実装するにはどうしたらよいか?
|
21
|
-
分からないので、
|
22
|
-
参考になるようなソースやサイトがあれば、
|
23
|
-
お願いします。
|
24
|
-
```
|
25
|
-
|
26
9
|
###該当のソースコード
|
27
|
-
|
10
|
+
プログラミング言語テーブル
|
28
11
|
```ここに言語を入力
|
29
|
-
<div class="col-sm-8">
|
30
|
-
<div class="panel panel-primary">
|
31
|
-
<div class="panel-heading">このページについて</div>
|
32
|
-
<div class="panel-body">こちらのサイトは企業が現在有しているITにおける作業環境が上位を示しています。</div>
|
33
|
-
</div>
|
34
|
-
<div class="panel panel-primary">
|
35
|
-
<div class="panel-heading">プログラミング言語取扱件数の上位3個</div>
|
36
|
-
<table class="table table-striped table-bordered">
|
37
|
-
<tbody>
|
38
|
-
<tr class="danger">
|
39
|
-
<th>順位</th>
|
40
|
-
<th>カウンター数</th>
|
41
|
-
<th>ITスキル名</th>
|
42
|
-
<th>備考</th>
|
43
|
-
</tr>
|
44
|
-
<tr>
|
45
|
-
<th></th>
|
46
|
-
<td></td>
|
47
|
-
<td></td>
|
48
|
-
</tr>
|
49
|
-
</tbody>
|
50
|
-
</table>
|
51
|
-
</div>
|
52
|
-
</div>
|
53
|
-
|
54
|
-
```
|
55
|
-
DBのプログラミング言語のカラム
|
56
|
-
```
|
57
12
|
class CreatePrograms < ActiveRecord::Migration
|
58
13
|
def change
|
59
14
|
create_table :programs do |t|
|
60
|
-
t.string :pmgcname
|
15
|
+
t.string :pmgcname #プログラミング言語名
|
61
|
-
t.integer :pmgcopemem
|
16
|
+
t.integer :pmgcopemem #出来る人の人数
|
62
|
-
t.integer :pmgshortagemem
|
17
|
+
t.integer :pmgshortagemem #この言語の仕事で不足してる人数
|
63
|
-
t.text :pmgRemarks
|
18
|
+
t.text :pmgRemarks #備考
|
64
19
|
|
65
20
|
t.timestamps null: false
|
66
21
|
end
|
67
22
|
end
|
68
23
|
end
|
24
|
+
|
69
25
|
```
|
70
26
|
プログラミング言語のコントローラー
|
71
27
|
```
|
@@ -143,12 +99,13 @@
|
|
143
99
|
params.require(:program).permit(:pmgcname, :pmgcopemem, :pmgshortagemem, :pmgRemarks)
|
144
100
|
end
|
145
101
|
end
|
146
|
-
|
147
102
|
```
|
148
103
|
ランキングのコントローラー
|
149
104
|
```
|
150
105
|
class RankingsController < ApplicationController
|
151
106
|
def programming
|
107
|
+
programmings = Program.group(:pmgcname).order('count_all desc').limit(10).count.keys
|
108
|
+
#@Programs = Program.find(pmgcnames).sort_by{|pmgcname| pmgcnames.index(pmgcname.pmgcname)}
|
152
109
|
end
|
153
110
|
|
154
111
|
def frameWork
|
@@ -177,7 +134,32 @@
|
|
177
134
|
end
|
178
135
|
|
179
136
|
```
|
137
|
+
ランキングのビュー
|
138
|
+
```
|
139
|
+
<div class="col-sm-8">
|
140
|
+
<div class="panel panel-primary">
|
141
|
+
<div class="panel-heading">このページについて</div>
|
142
|
+
<div class="panel-body">こちらのサイトは企業が現在有しているITにおける作業環境が上位を示しています。</div>
|
143
|
+
</div>
|
144
|
+
<div class="panel panel-primary">
|
145
|
+
<div class="panel-heading">プログラミング言語取扱件数の上位10個</div>
|
146
|
+
<table class="table table-striped table-bordered">
|
147
|
+
<tbody>
|
148
|
+
<tr class="danger">
|
149
|
+
<th>順位</th>
|
150
|
+
<th>カウンター数</th>
|
151
|
+
<th>ITスキル名</th>
|
152
|
+
</tr>
|
153
|
+
<td></td>
|
154
|
+
<td></td>
|
155
|
+
<td></td>
|
156
|
+
</tr>
|
157
|
+
</tbody>
|
158
|
+
</table>
|
159
|
+
</div>
|
160
|
+
</div>
|
180
161
|
|
162
|
+
```
|
181
163
|
|
182
164
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
183
|
-
Ruby
|
165
|
+
Ruby
|