Sha256: 697e7067adb41eb1265af9f9b5d0d8299c7893f7e15d15e766d4eaf93248b2ec

Contents?: true

Size: 754 Bytes

Versions: 7

Compression:

Stored size: 754 Bytes

Contents

class Curupira::RolesController < Curupira::AuthorizedController
  def index
    @roles = Role.all
  end

  def show
    @role = Role.find params[:id]
  end

  def new
    @role = Role.new
  end

  def edit
    @role = Role.find params[:id]
  end

  def create
    @role = Role.new role_params
    
    if @role.save
      redirect_to @role, notice: "Perfil criado com sucesso"
    else
      render :new
    end
  end

  def update
    @role = Role.find params[:id]

    if @role.update(role_params)
      redirect_to @role, notice: "Perfil atualizado com sucesso"
    else
      render :edit
    end
  end

  private

  def role_params
    params.require(:role).permit(:name, :active, authorizations_attributes: [:id, :feature_id, :_destroy])
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curupira-0.1.7 app/controllers/curupira/roles_controller.rb
curupira-0.1.6 app/controllers/curupira/roles_controller.rb
curupira-0.1.4 app/controllers/curupira/roles_controller.rb
curupira-0.1.3 app/controllers/curupira/roles_controller.rb
curupira-0.1.2 app/controllers/curupira/roles_controller.rb
curupira-0.1.1 app/controllers/curupira/roles_controller.rb
curupira-0.1.0 app/controllers/curupira/roles_controller.rb