diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-01-21 20:11:09 +0000 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-01-21 20:11:09 +0000 |
commit | 2f12b448f534f82765ef78e743e9f419c2c10572 (patch) | |
tree | 55bff093521f5fac258699612eb7fa71b2cc921d /web/web.rb | |
parent | 8aaa9645d1137b8c2f7b5bbf08fa3e3e1c8aa942 (diff) | |
download | lingo-2f12b448f534f82765ef78e743e9f419c2c10572.tar.gz lingo-2f12b448f534f82765ef78e743e9f419c2c10572.tar.bz2 lingo-2f12b448f534f82765ef78e743e9f419c2c10572.zip |
Fix populating user_id and updated_at fields on create
Diffstat (limited to 'web/web.rb')
-rw-r--r-- | web/web.rb | 4 |
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 | |||
10 | config = YAML.load(open("config.yml")) | 10 | config = YAML.load(open("config.yml")) |
11 | db = Sequel.connect("sqlite://#{config["database"]}") | 11 | db = Sequel.connect("sqlite://#{config["database"]}") |
12 | 12 | ||
13 | Sequel::Model.plugin :timestamps | 13 | Sequel::Model.plugin :timestamps, update_on_create: true |
14 | 14 | ||
15 | class LingoScore < Sequel::Model | 15 | class LingoScore < Sequel::Model |
16 | end | 16 | end |
@@ -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 |