2018-11-29 20:37:02 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-27 09:21:43 -04:00
|
|
|
class Staffs::PassportsController < ApplicationController
|
2018-11-29 23:31:08 -05:00
|
|
|
before_action :set_passport, except: %i[index new create]
|
2018-11-29 21:34:46 -05:00
|
|
|
|
2018-12-13 02:01:06 -05:00
|
|
|
# GET /staff/passports
|
2018-11-29 20:37:02 -05:00
|
|
|
def index
|
2018-12-12 21:21:12 -05:00
|
|
|
@passports = policy_scope(
|
|
|
|
Passport,
|
|
|
|
policy_scope_class: Staff::PassportPolicy::Scope,
|
|
|
|
)
|
2018-11-29 20:37:02 -05:00
|
|
|
end
|
2018-11-29 21:34:46 -05:00
|
|
|
|
2018-12-13 02:01:06 -05:00
|
|
|
# GET /staff/passports/:id
|
2018-11-29 21:34:46 -05:00
|
|
|
def show
|
2018-12-12 21:21:12 -05:00
|
|
|
authorize [:staff, @passport]
|
2018-12-02 18:00:18 -05:00
|
|
|
@passport.passport_maps.build if @passport.passport_map.nil?
|
2018-11-29 21:34:46 -05:00
|
|
|
end
|
|
|
|
|
2018-12-13 02:01:06 -05:00
|
|
|
# GET /staff/passports/new
|
2018-11-29 23:07:45 -05:00
|
|
|
def new
|
|
|
|
@passport = Passport.new
|
2018-12-02 15:29:39 -05:00
|
|
|
@passport.passport_maps.build
|
2018-11-29 23:31:08 -05:00
|
|
|
|
2018-12-12 21:21:12 -05:00
|
|
|
authorize [:staff, @passport]
|
2018-11-29 23:07:45 -05:00
|
|
|
end
|
|
|
|
|
2018-12-13 02:01:06 -05:00
|
|
|
# POST /staff/passports
|
2018-11-29 23:31:08 -05:00
|
|
|
def create
|
2018-12-12 21:21:12 -05:00
|
|
|
@passport = Passport.new permitted_attributes [:staff, Passport]
|
2018-11-29 23:31:08 -05:00
|
|
|
|
2018-12-12 21:21:12 -05:00
|
|
|
authorize [:staff, @passport]
|
2018-11-29 23:31:08 -05:00
|
|
|
|
|
|
|
return render :new unless @passport.save
|
|
|
|
|
2018-12-12 21:21:12 -05:00
|
|
|
redirect_to [:staff, @passport]
|
2018-11-29 23:31:08 -05:00
|
|
|
end
|
|
|
|
|
2018-11-29 21:34:46 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_passport
|
|
|
|
@passport = Passport.find params[:id]
|
|
|
|
end
|
2018-11-29 20:37:02 -05:00
|
|
|
end
|