Sha256: edd792e902bbfe2dbd426ba6c5029d87b619dcbeee3925ec369c02aa309b6d3b

Contents?: true

Size: 808 Bytes

Versions: 119

Compression:

Stored size: 808 Bytes

Contents

require_dependency "egov_utils/application_controller"

module EgovUtils
  class RolesController < ApplicationController
    def index
      authorize! :manage, User
      authorize! :manage, Group
      @users = User.all
      @groups = Group.all
    end

    def create
      entity = params[:entity_class].safe_constantize.try(:find, params[:id])
      return render_404 unless entity
      authorize! :manage, entity
      entity.roles = params[:roles].map(&:presence).compact if params[:roles].is_a?(Array)
      if entity.save
        respond_to do |format|
          format.json { render json: entity.roles }
        end
      else
        respond_to do |format|
          format.json { render json: entity.errors.full_messages, status: :unprocessable_entity }
        end
      end
    end
  end
end

Version data entries

119 entries across 119 versions & 1 rubygems

Version Path
egov_utils-1.5.0.alpha15 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha14 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha13 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha12 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha11 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha10 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha9 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha8 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha7 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha6 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha5 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha4 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.4.5 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.4.4 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha3 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha2 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.5.0.alpha1 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.4.3 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.4.2 app/controllers/egov_utils/roles_controller.rb
egov_utils-1.4.1 app/controllers/egov_utils/roles_controller.rb