adds booth backend for index, show, create and edit actions

This commit is contained in:
rgarcia
2016-09-28 11:56:19 +02:00
parent 7db3683c27
commit 2c3127b6bd
18 changed files with 288 additions and 85 deletions

View File

@@ -1,5 +1,8 @@
class Admin::Poll::BoothsController < Admin::BaseController
skip_authorization_check
load_and_authorize_resource :poll
load_and_authorize_resource class: 'Poll::Booth', through: :poll
before_action :load_polls, only: :index
def index
end
@@ -10,7 +13,33 @@ class Admin::Poll::BoothsController < Admin::BaseController
def new
end
def create
if @booth.save
redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.create.poll_booth")
else
render :new
end
end
def edit
end
def update
if @booth.update(booth_params)
redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.update.poll_booth")
else
render :edit
end
end
private
def booth_params
params.require(:poll_booth).permit(:name, :location)
end
def load_polls
@polls = Poll.all
end
end