diff options
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 | ||