Compare commits

..

1 Commits

Author SHA1 Message Date
Trevor Vallender a1f3de2e7a Diary entry basic functionality
Entries can be created, edited and viewed.
2023-12-29 14:27:09 +00:00
8 changed files with 29 additions and 15 deletions

View File

@ -50,6 +50,8 @@ class DiaryEntriesController < ApplicationController
:work_stress_level,
:life_stress_level,
:sleep_quality_level,
# exercise
# food
)
end
end

3
app/models/food.rb Normal file
View File

@ -0,0 +1,3 @@
class Food < ApplicationRecord
validates :name, presence: true
end

View File

@ -0,0 +1,9 @@
class CreateFoods < ActiveRecord::Migration[7.1]
def change
create_table :foods do |t|
t.text :name, null: false
t.timestamps
end
end
end

View File

@ -1,5 +0,0 @@
class DropFoods < ActiveRecord::Migration[7.1]
def change
drop_table :foods
end
end

View File

@ -1,6 +0,0 @@
class RenameAtOnExercises < ActiveRecord::Migration[7.1]
def change
remove_column :exercises, :at
add_column :exercises, :occurred_at, :datetime
end
end

10
db/schema.rb generated
View File

@ -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_29_121659) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -87,15 +87,21 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_143820) do
create_table "exercises", force: :cascade do |t|
t.bigint "exercise_type_id", null: false
t.time "at"
t.float "amount", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "diary_entry_id", null: false
t.datetime "occurred_at"
t.index ["diary_entry_id"], name: "index_exercises_on_diary_entry_id"
t.index ["exercise_type_id"], name: "index_exercises_on_exercise_type_id"
end
create_table "foods", force: :cascade do |t|
t.text "name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "microposts", force: :cascade do |t|
t.bigint "user_id", null: false
t.datetime "created_at", null: false

View File

@ -1,11 +1,11 @@
one:
exercise_type: running
occurred_at: 2023-12-29 11:41:45
at: 2023-12-29 11:41:45
amount: 5
diary_entry: one
two:
exercise_type: cycling
occurred_at: 2023-12-29 11:41:45
at: 2023-12-29 11:41:45
amount: 10.5
diary_entry: two

5
test/fixtures/foods.yml vendored Normal file
View File

@ -0,0 +1,5 @@
one:
name: Pizza
two:
name: Banana