From 0b4d3fbc200e646eed48a1a919dde9ee03678688 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 10 Dec 2022 11:38:57 -0500 Subject: Bot can submit to scoreboard now Also updated the scoreboard styling refs #13 --- rails/app/controllers/lingo/scores_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'rails/app/controllers') 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 @@ module Lingo class ScoresController < ApplicationController + skip_before_action :verify_authenticity_token, only: [:update] + def index @scores = Score.order(score: :desc) end @@ -8,13 +10,15 @@ module Lingo if params[:secret_code] != Lingo.secret_code then head :unauthorized else - score = Score.find_or_create_by(user_id: params[:user_id]) + score = Score.find_or_create_by(user_id: params[:user_id]) do |score| + score.score = 0 + end score.username = params[:username] - score.avatar_url = params[:avatar_url] + score.avatar_url = CGI.unescape(params[:avatar_url]) score.score += 1 score.save! - render :blank + head :created end end end -- cgit 1.4.1