Add exercise types

This commit is contained in:
Trevor Vallender 2023-12-29 11:39:20 +00:00
parent 7615febc5d
commit 500f5bd02e
4 changed files with 30 additions and 1 deletions

View File

@ -0,0 +1,5 @@
class ExerciseType < ApplicationRecord
validates :name,
:unit,
presence: true
end

View File

@ -0,0 +1,10 @@
class CreateExerciseTypes < ActiveRecord::Migration[7.1]
def change
create_table :exercise_types do |t|
t.text :name, null: false
t.text :unit, null: false
t.timestamps
end
end
end

9
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_112620) do
ActiveRecord::Schema[7.1].define(version: 2023_12_29_112847) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -63,6 +63,13 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_112620) do
t.index ["user_id"], name: "index_blog_posts_on_user_id"
end
create_table "exercise_types", force: :cascade do |t|
t.text "name", null: false
t.text "unit", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "foods", force: :cascade do |t|
t.text "name", null: false
t.datetime "created_at", null: false

7
test/fixtures/exercise_types.yml vendored Normal file
View File

@ -0,0 +1,7 @@
running:
name: Running
unit: km
cycling:
name: Running
unit: km