Skip to content

Commit 42f6ed3

Browse files
committed
Adds ability to delete a website page
1 parent 4971c9e commit 42f6ed3

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

app/controllers/staff/pages_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def promote
4949
redirect_to event_staff_pages_path(current_event)
5050
end
5151

52+
def destroy
53+
@page.destroy
54+
flash[:success] = "#{@page.name} Page was successfully destroyed."
55+
redirect_to event_staff_pages_path(current_event)
56+
end
57+
5258
private
5359

5460
def set_page

app/policies/page_policy.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ def publish?
3434
def promote?
3535
new?
3636
end
37+
38+
def destroy?
39+
new?
40+
end
3741
end

app/views/staff/pages/_page.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
class: 'btn btn-primary')
2222
- if page.published_body.present?
2323
= link_to("View", page_path(current_event, page), class: 'btn btn-primary')
24+
= link_to 'Destroy', event_staff_page_path(@event, page), method: :delete, data: { confirm: 'Are you sure you want to delete this page?' }, class: "btn btn-danger"

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
resources :session_formats, except: :show
120120
resources :tracks, except: [:show]
121121
resource :website, only: [:new, :create, :edit, :update]
122-
resources :pages, except: :destroy do
122+
resources :pages do
123123
member do
124124
get :preview
125125
patch :publish

0 commit comments

Comments
 (0)