Simplify URL to destroy a booth assignment
We can find the booth through the booth assignment, so we don't need to pass it in the URL. Since the parameter is in the URL and not sent through a form, we can also use `params[:poll_id]` directly, and so we can reuse the `load_poll` method.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
|
||||
before_action :load_poll, except: [:create, :destroy]
|
||||
before_action :load_poll, except: [:create]
|
||||
|
||||
def index
|
||||
@booth_assignments = @poll.booth_assignments.includes(:booth).order("poll_booths.name")
|
||||
@@ -36,9 +36,8 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@poll = Poll.find(booth_assignment_params[:poll_id])
|
||||
@booth = Poll::Booth.find(booth_assignment_params[:booth_id])
|
||||
@booth_assignment = ::Poll::BoothAssignment.find(params[:id])
|
||||
@booth_assignment = @poll.booth_assignments.find(params[:id])
|
||||
@booth = @booth_assignment.booth
|
||||
|
||||
@booth_assignment.destroy!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user