Implement deletion of announcements
This commit is contained in:
parent
e3b89f7346
commit
f14a168bce
|
@ -19,12 +19,19 @@ class AnnouncementController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@announcement = Announcement.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
private
|
||||
|
|
|
@ -5,4 +5,10 @@
|
|||
= link_to "Add new", :announcement_new, class: "btn btn-default"
|
||||
- @announcements.each do |announcement|
|
||||
.panel.panel-default
|
||||
= announcement.content
|
||||
.panel-heading
|
||||
= announcement.starts_at
|
||||
.panel-body
|
||||
= 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