Sha256: d312f52bbca25a343810ea675d4508392ff36339794a42aeae3ceb6bc835e164

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require_dependency "authz/application_controller"

module Authz
  class BusinessProcessesController < ApplicationController
    def index
      @business_processes = BusinessProcess.all.order(created_at: :desc).page(params[:business_processes_page])
    end

    def show
      @business_process = BusinessProcess.find(params[:id])
      @associated_controller_actions = @business_process.controller_actions.distinct.page(params[:controller_actions_page]).per(10)
      @associated_roles = @business_process.roles.distinct.page(params[:roles_page]).per(10)
      # @all_rolables = []
      # Authz.rolables.each do |rolable|
      #   @all_rolables << @business_process.public_send(rolable.pluralizado).page(params["#{}_page"])
      # end
    end

    def new
      @business_process = BusinessProcess.new
    end

    def create
      @business_process = BusinessProcess.new(business_process_params)
      if @business_process.save
        redirect_to business_process_path(@business_process)
      else
        render 'new'
      end
    end

    def edit
      @business_process = BusinessProcess.find(params[:id])
    end

    def update
      @business_process = BusinessProcess.find(params[:id])
      if @business_process.update(business_process_params)
        redirect_to business_process_path(@business_process)
      else
        render 'edit'
      end
    end

    def destroy
      @business_process = BusinessProcess.find(params[:id])
      if @business_process.destroy
        redirect_to business_processes_path
      else
        render 'show'
      end
    end

    private

    def business_process_params
      params.require(:business_process)
            .permit(
              :name,
              :description,
              controller_action_ids: [],
              role_ids: []
            )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authz-0.0.1.alpha3 app/controllers/authz/business_processes_controller.rb
authz-0.0.1.alpha2 app/controllers/authz/business_processes_controller.rb