Add button to delete a poll

This commit is contained in:
decabeza
2019-05-14 16:46:56 +02:00
parent a1d6885132
commit e026412389
7 changed files with 77 additions and 4 deletions

View File

@@ -58,6 +58,16 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
@polls = Poll.current
end
def destroy
if ::Poll::Voter.where(poll: @poll).any?
redirect_to admin_poll_path(@poll), alert: t("admin.polls.destroy.unable_notice")
else
@poll.destroy
redirect_to admin_polls_path, notice: t("admin.polls.destroy.success_notice")
end
end
private
def load_geozones