Add Todos for learning goals
This commit is contained in:
parent
658bc90ed7
commit
084f965b25
|
@ -3,6 +3,7 @@ class LearningGoal < ApplicationRecord
|
||||||
|
|
||||||
has_rich_text :description
|
has_rich_text :description
|
||||||
has_rich_text :retrospective
|
has_rich_text :retrospective
|
||||||
|
validates :completed, inclusion: { in: [true, false] }
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
class Todo < ApplicationRecord
|
||||||
|
belongs_to :learning_goal
|
||||||
|
validates :done, inclusion: { in: [true, false] }
|
||||||
|
end
|
|
@ -0,0 +1,12 @@
|
||||||
|
class CreateTodos < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
create_table :todos do |t|
|
||||||
|
t.belongs_to :learning_goal, null: false, foreign_key: true
|
||||||
|
t.boolean :done, null: false, default: false
|
||||||
|
t.string :title, null: false, default: ''
|
||||||
|
t.date :due
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.1].define(version: 2024_01_06_103226) do
|
ActiveRecord::Schema[7.1].define(version: 2024_01_07_131738) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -140,6 +140,16 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_06_103226) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "todos", force: :cascade do |t|
|
||||||
|
t.bigint "learning_goal_id", null: false
|
||||||
|
t.boolean "done", default: false, null: false
|
||||||
|
t.string "title", default: "", null: false
|
||||||
|
t.date "due"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["learning_goal_id"], name: "index_todos_on_learning_goal_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "users", force: :cascade do |t|
|
create_table "users", force: :cascade do |t|
|
||||||
t.string "username", null: false
|
t.string "username", null: false
|
||||||
t.string "password_digest", null: false
|
t.string "password_digest", null: false
|
||||||
|
@ -161,4 +171,5 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_06_103226) do
|
||||||
add_foreign_key "exercises", "exercise_types"
|
add_foreign_key "exercises", "exercise_types"
|
||||||
add_foreign_key "learning_goals", "users"
|
add_foreign_key "learning_goals", "users"
|
||||||
add_foreign_key "microposts", "users"
|
add_foreign_key "microposts", "users"
|
||||||
|
add_foreign_key "todos", "learning_goals"
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
one:
|
||||||
|
learning_goal: sql
|
||||||
|
done: false
|
||||||
|
title: Read ‘SQL for Mere Mortals’
|
||||||
|
due: <%= 3.years.from_now %>
|
||||||
|
|
||||||
|
two:
|
||||||
|
learning_goal: linux
|
||||||
|
done: true
|
||||||
|
title: Install Debian
|
|
@ -0,0 +1,7 @@
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class TodoTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Loading…
Reference in New Issue