From 4caf9370199d6230d667dd5ee9a35208b9b15528 Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Sun, 22 Sep 2024 20:50:55 +0200 Subject: [PATCH] pimp view wip --- mood.rb | 1 + mood_app.rb | 2 +- views/index.erb | 78 +++++++++++++++++++++++++++++++++++++------------ 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/mood.rb b/mood.rb index 21e3c9a..b7bcf91 100644 --- a/mood.rb +++ b/mood.rb @@ -1,4 +1,5 @@ class Mood < ActiveRecord::Base + default_scope { order(:recorded_at) } validates_presence_of :mode validates_presence_of :recorded_at diff --git a/mood_app.rb b/mood_app.rb index 50692d3..134ea14 100644 --- a/mood_app.rb +++ b/mood_app.rb @@ -9,7 +9,7 @@ class MoodApp < Sinatra::Base set :database, { adapter: 'sqlite3', database: "mood-#{ENV['RACK_ENV']}.sqlite3" } get '/' do - @last_mood = Mood.order(recorded_at: :desc).first + @last_mood = Mood.last @mood_log = Mood.log erb :index end diff --git a/views/index.erb b/views/index.erb index 25f6e9b..dab8bd2 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1,15 +1,25 @@