From 2f12b448f534f82765ef78e743e9f419c2c10572 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 21 Jan 2025 20:11:09 +0000 Subject: Fix populating user_id and updated_at fields on create --- web/web.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/web.rb b/web/web.rb index 8685de3..4d424ec 100644 --- a/web/web.rb +++ b/web/web.rb @@ -10,7 +10,7 @@ use Rack::Cache config = YAML.load(open("config.yml")) db = Sequel.connect("sqlite://#{config["database"]}") -Sequel::Model.plugin :timestamps +Sequel::Model.plugin :timestamps, update_on_create: true class LingoScore < Sequel::Model end @@ -26,7 +26,7 @@ post '/update' do 403 else if LingoScore.where(user_id: params[:user_id]).count == 0 - score = LingoScore.new(score: 0) + score = LingoScore.new(score: 0, user_id: params[:user_id]) else score = LingoScore.first(user_id: params[:user_id]) end -- cgit 1.4.1