Sha256: 2c1cac7c725f0a69b6962ce0bee41049362b7d9c4797681e0cd675d555e4c5c0

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 KB

Contents

class ClearancesController < ApplicationController
  before_action :set_clearance, only: [:edit, :update, :destroy]

  # GET /clearances
  def index
    authorize skip_scoping: true
    @clearances = apply_authz_scopes(on: Clearance)
  end


  # GET /clearances/new
  def new
    authorize skip_scoping: true
    @clearance = Clearance.new
  end

  # GET /clearances/1/edit
  def edit
    authorize using: @clearance
  end

  # POST /clearances
  def create
    @clearance = Clearance.new(clearance_params)
    authorize using: @clearance

    if @clearance.save
      redirect_to clearances_url, notice: 'Clearance was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /clearances/1
  def update
    @clearance.assign_attributes(clearance_params)
    authorize using: @clearance
    if @clearance.save
      redirect_to clearances_url, notice: 'Clearance was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /clearances/1
  def destroy
    authorize using: @clearance
    @clearance.destroy
    redirect_to clearances_url, notice: 'Clearance was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_clearance
      @clearance = Clearance.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def clearance_params
      params.require(:clearance).permit(:level, :name)
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
authz-0.0.5 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.4 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.3 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.2 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.1 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.1.alpha5 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.1.alpha4 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.1.alpha3 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.1.alpha2 spec/dummy/app/controllers/clearances_controller.rb
authz-0.0.1.alpha spec/dummy/app/controllers/clearances_controller.rb