From af1bd3b3741faa82b9b323a4caa435dcc9a36ede Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Wed, 5 Mar 2025 17:33:10 +0100 Subject: [PATCH] fix bug when no mood recorded --- mood_app.rb | 4 ++-- views/index.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mood_app.rb b/mood_app.rb index dd1f39e..23da0be 100644 --- a/mood_app.rb +++ b/mood_app.rb @@ -10,8 +10,8 @@ class MoodApp < Sinatra::Base set :database, { adapter: 'sqlite3', database: "mood-#{ENV['RACK_ENV']}.sqlite3" } get '/' do - @last_mood = Mood.last - @mood_log = Mood.log + @mode = Mood.last&.mode || 'croisiere' + @mood_log = Mood.log || [] erb :index end diff --git a/views/index.erb b/views/index.erb index 9d13c6b..bed99f7 100644 --- a/views/index.erb +++ b/views/index.erb @@ -14,7 +14,7 @@ showCurrent() { const image = this.imageTarget - image.src = "<%= @last_mood.mode %>.png" + image.src = "<%= @mode %>.png" } }) @@ -107,7 +107,7 @@ tbody tr td {
- +