diff --git a/app/controllers/puzzles_controller.rb b/app/controllers/puzzles_controller.rb index 0b9584a..f559c20 100644 --- a/app/controllers/puzzles_controller.rb +++ b/app/controllers/puzzles_controller.rb @@ -53,6 +53,6 @@ class PuzzlesController < ApplicationController end def puzzle_params - params.expect(puzzle: [ :name, :image ]) + params.expect(puzzle: [ :brand, :name, :image ]) end end diff --git a/app/models/puzzle.rb b/app/models/puzzle.rb index 37f8765..8ccb780 100644 --- a/app/models/puzzle.rb +++ b/app/models/puzzle.rb @@ -2,4 +2,5 @@ class Puzzle < ApplicationRecord belongs_to :contest has_one_attached :image validates :name, presence: true + validates :brand, presence: true end diff --git a/app/views/contests/show.html.slim b/app/views/contests/show.html.slim index 97f1546..744a68f 100644 --- a/app/views/contests/show.html.slim +++ b/app/views/contests/show.html.slim @@ -27,7 +27,7 @@ = image_tag puzzle.image if puzzle.image.attached? .card-body p.card-text - | TODO puzzle.brand + = puzzle.brand a.stretched-link href=edit_contest_puzzle_path(@contest, puzzle) .row .col diff --git a/app/views/puzzles/_form.html.slim b/app/views/puzzles/_form.html.slim index 0cc8255..a4490a6 100644 --- a/app/views/puzzles/_form.html.slim +++ b/app/views/puzzles/_form.html.slim @@ -4,6 +4,11 @@ .form-floating = form.text_field :name, autocomplete: "off", class: "form-control" = form.label :name, class: "required" + .row.mb-3 + .col + .form-floating + = form.text_field :brand, autocomplete: "off", class: "form-control" + = form.label :brand, class: "required" .row.mb-3 .col .form-text Select an image diff --git a/db/migrate/20250320075601_add_brand_to_puzzle.rb b/db/migrate/20250320075601_add_brand_to_puzzle.rb new file mode 100644 index 0000000..3378030 --- /dev/null +++ b/db/migrate/20250320075601_add_brand_to_puzzle.rb @@ -0,0 +1,5 @@ +class AddBrandToPuzzle < ActiveRecord::Migration[8.0] + def change + add_column :puzzles, :brand, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bfcb963..3d047b2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_03_15_124339) do +ActiveRecord::Schema[8.0].define(version: 2025_03_20_075601) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -54,6 +54,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_15_124339) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "contest_id", null: false + t.string "brand" t.index ["contest_id"], name: "index_puzzles_on_contest_id" end