diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-12-10 11:38:57 -0500 | 
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-12-10 11:39:29 -0500 | 
| commit | 0b4d3fbc200e646eed48a1a919dde9ee03678688 (patch) | |
| tree | 123fed7ecf90a22618a8814ecca60d0e48567fb6 /rails/app/controllers | |
| parent | 0380a97230023a78ad08b738c4520e901485ed63 (diff) | |
| download | lingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.tar.gz lingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.tar.bz2 lingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.zip  | |
Bot can submit to scoreboard now
Also updated the scoreboard styling refs #13
Diffstat (limited to 'rails/app/controllers')
| -rw-r--r-- | rails/app/controllers/lingo/scores_controller.rb | 10 | 
1 files changed, 7 insertions, 3 deletions
| diff --git a/rails/app/controllers/lingo/scores_controller.rb b/rails/app/controllers/lingo/scores_controller.rb index 63fd0f9..59bbd9d 100644 --- a/rails/app/controllers/lingo/scores_controller.rb +++ b/rails/app/controllers/lingo/scores_controller.rb | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | module Lingo | 1 | module Lingo | 
| 2 | class ScoresController < ApplicationController | 2 | class ScoresController < ApplicationController | 
| 3 | skip_before_action :verify_authenticity_token, only: [:update] | ||
| 4 | |||
| 3 | def index | 5 | def index | 
| 4 | @scores = Score.order(score: :desc) | 6 | @scores = Score.order(score: :desc) | 
| 5 | end | 7 | end | 
| @@ -8,13 +10,15 @@ module Lingo | |||
| 8 | if params[:secret_code] != Lingo.secret_code then | 10 | if params[:secret_code] != Lingo.secret_code then | 
| 9 | head :unauthorized | 11 | head :unauthorized | 
| 10 | else | 12 | else | 
| 11 | score = Score.find_or_create_by(user_id: params[:user_id]) | 13 | score = Score.find_or_create_by(user_id: params[:user_id]) do |score| | 
| 14 | score.score = 0 | ||
| 15 | end | ||
| 12 | score.username = params[:username] | 16 | score.username = params[:username] | 
| 13 | score.avatar_url = params[:avatar_url] | 17 | score.avatar_url = CGI.unescape(params[:avatar_url]) | 
| 14 | score.score += 1 | 18 | score.score += 1 | 
| 15 | score.save! | 19 | score.save! | 
| 16 | 20 | ||
| 17 | render :blank | 21 | head :created | 
| 18 | end | 22 | end | 
| 19 | end | 23 | end | 
| 20 | end | 24 | end | 
