diff --git a/db/migrate/20250321213011_create_votes.rb b/db/migrate/20250321213011_create_votes.rb index 321e58f..70f6281 100644 --- a/db/migrate/20250321213011_create_votes.rb +++ b/db/migrate/20250321213011_create_votes.rb @@ -5,7 +5,7 @@ class CreateVotes < ActiveRecord::Migration[7.2] t.string :title t.text :description t.datetime :expire_on - t.timestamps null: false + t.timestamps end end end diff --git a/db/migrate/20250321224552_create_candidates.rb b/db/migrate/20250321224552_create_candidates.rb new file mode 100644 index 0000000..e69b0d2 --- /dev/null +++ b/db/migrate/20250321224552_create_candidates.rb @@ -0,0 +1,10 @@ +class CreateCandidates < ActiveRecord::Migration[7.2] + def change + create_table :candidates do |t| + t.belongs_to :vote + t.string :name + t.text :description + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8245e87..ca192cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,16 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2025_03_21_213011) do +ActiveRecord::Schema[7.2].define(version: 2025_03_21_224552) do + create_table "candidates", force: :cascade do |t| + t.integer "vote_id" + t.string "name" + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["vote_id"], name: "index_candidates_on_vote_id" + end + create_table "votes", force: :cascade do |t| t.string "secure_id" t.string "title" diff --git a/views/home.erb b/views/home.erb index 962ec6b..520e4db 100644 --- a/views/home.erb +++ b/views/home.erb @@ -4,11 +4,13 @@