diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-12-10 09:29:30 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-12-10 09:29:30 -0500 |
commit | 0380a97230023a78ad08b738c4520e901485ed63 (patch) | |
tree | 2f3b4e91453962fd5bb36cf652c808cb7f41c3a7 /rails/app/controllers | |
parent | 6af7b09fa551c6cc980bb54fefd1db88c904654f (diff) | |
download | lingo-0380a97230023a78ad08b738c4520e901485ed63.tar.gz lingo-0380a97230023a78ad08b738c4520e901485ed63.tar.bz2 lingo-0380a97230023a78ad08b738c4520e901485ed63.zip |
Added Rails engine for scoreboard
refs #13
Diffstat (limited to 'rails/app/controllers')
-rw-r--r-- | rails/app/controllers/concerns/.keep | 0 | ||||
-rw-r--r-- | rails/app/controllers/lingo/application_controller.rb | 4 | ||||
-rw-r--r-- | rails/app/controllers/lingo/scores_controller.rb | 21 |
3 files changed, 25 insertions, 0 deletions
diff --git a/rails/app/controllers/concerns/.keep b/rails/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails/app/controllers/concerns/.keep | |||
diff --git a/rails/app/controllers/lingo/application_controller.rb b/rails/app/controllers/lingo/application_controller.rb new file mode 100644 index 0000000..33f4567 --- /dev/null +++ b/rails/app/controllers/lingo/application_controller.rb | |||
@@ -0,0 +1,4 @@ | |||
1 | module Lingo | ||
2 | class ApplicationController < ActionController::Base | ||
3 | end | ||
4 | end | ||
diff --git a/rails/app/controllers/lingo/scores_controller.rb b/rails/app/controllers/lingo/scores_controller.rb new file mode 100644 index 0000000..63fd0f9 --- /dev/null +++ b/rails/app/controllers/lingo/scores_controller.rb | |||
@@ -0,0 +1,21 @@ | |||
1 | module Lingo | ||
2 | class ScoresController < ApplicationController | ||
3 | def index | ||
4 | @scores = Score.order(score: :desc) | ||
5 | end | ||
6 | |||
7 | def update | ||
8 | if params[:secret_code] != Lingo.secret_code then | ||
9 | head :unauthorized | ||
10 | else | ||
11 | score = Score.find_or_create_by(user_id: params[:user_id]) | ||
12 | score.username = params[:username] | ||
13 | score.avatar_url = params[:avatar_url] | ||
14 | score.score += 1 | ||
15 | score.save! | ||
16 | |||
17 | render :blank | ||
18 | end | ||
19 | end | ||
20 | end | ||
21 | end | ||