Allow to delete puzzles
This commit is contained in:
parent
785e523ebe
commit
6f07ec802f
@ -39,7 +39,7 @@ class PuzzlesController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@puzzle.destroy
|
@puzzle.destroy
|
||||||
redirect_to puzzles_path
|
redirect_to contest_path(@contest)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class Contest < ApplicationRecord
|
class Contest < ApplicationRecord
|
||||||
belongs_to :user, dependent: :destroy
|
belongs_to :user
|
||||||
has_many :puzzles
|
has_many :puzzles, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class Puzzle < ApplicationRecord
|
class Puzzle < ApplicationRecord
|
||||||
belongs_to :contest, dependent: :destroy
|
belongs_to :contest
|
||||||
has_one_attached :image
|
has_one_attached :image
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
end
|
end
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
.col
|
.col
|
||||||
.form-text Select an image
|
.form-text Select an image
|
||||||
= form.file_field :image, accept: "image/*", class: "form-control"
|
= form.file_field :image, accept: "image/*", class: "form-control"
|
||||||
.row
|
.row.mt-4
|
||||||
.col
|
.col
|
||||||
|
- if method == :patch
|
||||||
|
= link_to "Delete", contest_puzzle_path(contest, puzzle), data: { turbo_method: :delete }, class: "btn btn-danger me-2"
|
||||||
= form.submit submit_text, class: "btn btn-primary"
|
= form.submit submit_text, class: "btn btn-primary"
|
Loading…
x
Reference in New Issue
Block a user