Sha256: 0d3f0c35a1b7c84e954aaabbf5b36be44a4e2fc42c1d983fb3eb549e80fbd810

Contents?: true

Size: 811 Bytes

Versions: 6

Compression:

Stored size: 811 Bytes

Contents

require_dependency "authz/application_controller"

module Authz
  class Validations::BusinessProcessNamesController < ApplicationController
    def new
      name = params[:business_process][:name]
      # found = BusinessProcess.exists?(name: name)
      found = BusinessProcess.exists?(code: name.parameterize(separator: '_'))

      respond_to do |format|
        format.json {render :json => !found}
      end
    end

    def edit
      name = params[:business_process][:name]
      business_process = BusinessProcess.find_by(code: name.parameterize(separator: '_'))
      # found = BusinessProcess.exists?(name: name)

      found = business_process.present? && business_process.id != params[:id].to_i
      respond_to do |format|
        format.json {render :json => !found}
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
authz-0.0.2 app/controllers/authz/validations/business_process_names_controller.rb
authz-0.0.1 app/controllers/authz/validations/business_process_names_controller.rb
authz-0.0.1.alpha5 app/controllers/authz/validations/business_process_names_controller.rb
authz-0.0.1.alpha4 app/controllers/authz/validations/business_process_names_controller.rb
authz-0.0.1.alpha3 app/controllers/authz/validations/business_process_names_controller.rb
authz-0.0.1.alpha2 app/controllers/authz/validations/business_process_names_controller.rb