adds complete Booth management to admin
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
class Admin::Poll::BoothsController < Admin::BaseController
|
||||
load_and_authorize_resource :poll
|
||||
load_and_authorize_resource class: 'Poll::Booth', through: :poll
|
||||
|
||||
before_action :load_polls, only: :index
|
||||
load_and_authorize_resource class: 'Poll::Booth'
|
||||
|
||||
def index
|
||||
@booths = @booths.order(name: :asc).page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
@officers = Poll::Officer.all
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -16,7 +13,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
|
||||
|
||||
def create
|
||||
if @booth.save
|
||||
redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.create.poll_booth")
|
||||
redirect_to admin_booths_path, notice: t("flash.actions.create.poll_booth")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
@@ -27,7 +24,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
|
||||
|
||||
def update
|
||||
if @booth.update(booth_params)
|
||||
redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.update.poll_booth")
|
||||
redirect_to admin_booth_path(@booth), notice: t("flash.actions.update.poll_booth")
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
@@ -36,11 +33,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def booth_params
|
||||
params.require(:poll_booth).permit(:name, :location, officer_ids: [])
|
||||
end
|
||||
|
||||
def load_polls
|
||||
@polls = Poll.all
|
||||
params.require(:poll_booth).permit(:name, :location)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user