Sha256: 2ea3147a3dbf1e2f1a1fc547fe40cadf2a4fdbc14c527234877d3ce3f0d9b5ad

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

class AbilitiesController < ApplicationController

  before_filter :check_permissions

  def index
    @abilities = Ability.order(:name)
  end

  def show
    @ability = Ability.find(params[:id])
  end

  def new
    @ability = Ability.new
  end

  def create
    @ability = Ability.new(ability_params)
    if @ability.save
      flash[:notice] = t('ability.created')
      redirect_to :action => :index
    else
      render 'new'
    end
  end


  def edit
    @ability = Ability.find(params[:id])
  end

  def update
    @ability = Ability.find(params[:id])

    if @ability.update_attributes(ability_params)
      flash[:notice] = t('ability.saved')
      redirect_to :action => :index
    else
      render 'edit'
    end
  end

  protected

  def ability_params
    params.require(:ability).permit(:name, :description,
      :ability_permissions_attributes => [:id, :permission_id, :_destroy,
                                          :permission_attributes => [:id, :allowed_action, :_destroy]
                                         ]
    )
  end


end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vigilante-1.0.17 app/controllers/abilities_controller.rb
vigilante-1.0.16 app/controllers/abilities_controller.rb
vigilante-1.0.15 app/controllers/abilities_controller.rb
vigilante-1.0.14 app/controllers/abilities_controller.rb