Sha256: 5b8ec6d8ec3601a4d21afdf50e9a2eb16bf294c90a462a7ebb7f506247603591

Contents?: true

Size: 767 Bytes

Versions: 7

Compression:

Stored size: 767 Bytes

Contents

class Curupira::GroupsController < Curupira::AuthorizedController
  def index
    @groups = Group.all
  end

  def show
    @group = Group.find(params[:id])
  end

  def new
    @group = Group.new
  end

  def edit
    @group = Group.find(params[:id])
  end

  def create
    @group = Group.new(group_params)

    if @group.save
      redirect_to @group, notice: "Grupo criado com sucesso"
    else
      render :new
    end
  end

  def update
    @group = Group.find(params[:id])

    if @group.update group_params
      redirect_to @group, notice: "Grupo atualizado com sucesso"
    else
      render :edit
    end
  end

  private

  def group_params
    params.require(:group).permit(:name, :active, role_groups_attributes: [:id, :role_id, :_destroy])
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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