Add weight tracking
This commit is contained in:
parent
4170bb9b3e
commit
4107aa61d4
|
@ -1,5 +1,5 @@
|
|||
class DiaryEntriesController < ApplicationController
|
||||
before_action :set_diary_entry, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_diary_entry, only: [:show, :edit, :update]
|
||||
|
||||
def index
|
||||
@diary_entries = DiaryEntry.all
|
||||
|
@ -50,6 +50,7 @@ class DiaryEntriesController < ApplicationController
|
|||
:work_stress_level,
|
||||
:life_stress_level,
|
||||
:sleep_quality_level,
|
||||
:weight,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,5 +9,16 @@ class DiaryEntry < ApplicationRecord
|
|||
:work_stress_level,
|
||||
:life_stress_level,
|
||||
:sleep_quality_level,
|
||||
:weight,
|
||||
presence: true
|
||||
|
||||
validates :pain_level,
|
||||
:energy_level,
|
||||
:mental_alertness_level,
|
||||
:work_stress_level,
|
||||
:life_stress_level,
|
||||
:sleep_quality_level,
|
||||
numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
|
||||
|
||||
validates :weight, numericality: { greater_than_or_equal_to: 0 }
|
||||
end
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
<%= f.label :sleep_quality_level %>
|
||||
<%= f.number_field :sleep_quality_level %>
|
||||
|
||||
<%= f.label :weight %>
|
||||
<%= f.number_field :weight %>
|
||||
|
||||
<%= f.label :notes %>
|
||||
<%= f.text_area :notes %>
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<th><%= t(".work_stress_level") %></th>
|
||||
<th><%= t(".life_stress_level") %></th>
|
||||
<th><%= t(".sleep_quality_level") %></th>
|
||||
<th><%= t(".weight") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -17,6 +18,7 @@
|
|||
<td><%= diary_entry.work_stress_level %></td>
|
||||
<td><%= diary_entry.life_stress_level %></td>
|
||||
<td><%= diary_entry.sleep_quality_level %></td>
|
||||
<td><%= diary_entry.weight %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -23,3 +23,4 @@ en:
|
|||
work_stress_level: Work Stress
|
||||
life_stress_level: Life Stress
|
||||
sleep_quality_level: Sleep Quality
|
||||
weight: Weight
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddWeightToDiaryEntry < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :diary_entries, :weight, :float
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2023_12_29_143820) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2023_12_31_112357) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -75,6 +75,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_143820) do
|
|||
t.integer "sleep_quality_level", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.float "weight"
|
||||
t.index ["user_id"], name: "index_diary_entries_on_user_id"
|
||||
end
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ one:
|
|||
work_stress_level: 10
|
||||
life_stress_level: 10
|
||||
sleep_quality_level: 10
|
||||
weight: 86
|
||||
|
||||
two:
|
||||
user: trevor
|
||||
|
@ -19,3 +20,4 @@ two:
|
|||
work_stress_level: 1
|
||||
life_stress_level: 1
|
||||
sleep_quality_level: 10
|
||||
weight: 89
|
||||
|
|
Loading…
Reference in New Issue