summary refs log tree commit diff stats
path: root/web
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-01-21 20:11:09 +0000
committerStar Rauchenberger <fefferburbia@gmail.com>2025-01-21 20:11:09 +0000
commit2f12b448f534f82765ef78e743e9f419c2c10572 (patch)
tree55bff093521f5fac258699612eb7fa71b2cc921d /web
parent8aaa9645d1137b8c2f7b5bbf08fa3e3e1c8aa942 (diff)
downloadlingo-2f12b448f534f82765ef78e743e9f419c2c10572.tar.gz
lingo-2f12b448f534f82765ef78e743e9f419c2c10572.tar.bz2
lingo-2f12b448f534f82765ef78e743e9f419c2c10572.zip
Fix populating user_id and updated_at fields on create
Diffstat (limited to 'web')
-rw-r--r--web/web.rb4
1 files 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
10config = YAML.load(open("config.yml")) 10config = YAML.load(open("config.yml"))
11db = Sequel.connect("sqlite://#{config["database"]}") 11db = Sequel.connect("sqlite://#{config["database"]}")
12 12
13Sequel::Model.plugin :timestamps 13Sequel::Model.plugin :timestamps, update_on_create: true
14 14
15class LingoScore < Sequel::Model 15class LingoScore < Sequel::Model
16end 16end
@@ -26,7 +26,7 @@ post '/update' do
26 403 26 403
27 else 27 else
28 if LingoScore.where(user_id: params[:user_id]).count == 0 28 if LingoScore.where(user_id: params[:user_id]).count == 0
29 score = LingoScore.new(score: 0) 29 score = LingoScore.new(score: 0, user_id: params[:user_id])
30 else 30 else
31 score = LingoScore.first(user_id: params[:user_id]) 31 score = LingoScore.first(user_id: params[:user_id])
32 end 32 end