Implement deletion of announcements
This commit is contained in:
parent
e3b89f7346
commit
f14a168bce
|
@ -19,12 +19,19 @@ class AnnouncementController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@announcement = Announcement.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
if Announcement.destroy(params[:id])
|
||||||
|
flash[:success] = "Announcement deleted successfully."
|
||||||
|
else
|
||||||
|
flash[:error] = "Failed to delete announcement."
|
||||||
|
end
|
||||||
|
redirect_to announcement_index_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -5,4 +5,10 @@
|
||||||
= link_to "Add new", :announcement_new, class: "btn btn-default"
|
= link_to "Add new", :announcement_new, class: "btn btn-default"
|
||||||
- @announcements.each do |announcement|
|
- @announcements.each do |announcement|
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
= announcement.starts_at
|
||||||
|
.panel-body
|
||||||
= announcement.content
|
= announcement.content
|
||||||
|
.panel-footer
|
||||||
|
= button_to "Edit", announcement_edit_path(id: announcement.id), class: 'btn btn-link'
|
||||||
|
= button_to "Delete", announcement_destroy_path(id: announcement.id), method: :delete, class: 'btn btn-link', confirm: 'Are you sure you want to delete this announcement?'
|
Loading…
Reference in New Issue