Sha256: 26858dbff0902a7db5204f51f58340b8bad06630f68037731746e2f7d58fb26a

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

class Gamification::ItemTypesController < ApplicationController
  before_action :set_gamification_item_type, only: [:show, :edit, :update, :destroy]
  before_action :authenticate_user!
  load_and_authorize_resource except: [:create]
  # GET /gamification/item_types
  def index
    @gamification_item_types = Gamification::ItemType.all
  end

  # GET /gamification/item_types/1
  def show
  end

  # GET /gamification/item_types/new
  def new
    @gamification_item_type = Gamification::ItemType.new
  end

  # GET /gamification/item_types/1/edit
  def edit
  end

  # POST /gamification/item_types
  def create
    authorize! :create, @gamification_item_type

    @gamification_item_type = Gamification::ItemType.new(gamification_item_type_params)

    if @gamification_item_type.save
      redirect_to @gamification_item_type, notice: 'Item type was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /gamification/item_types/1
  def update
    if @gamification_item_type.update(gamification_item_type_params)
      redirect_to @gamification_item_type, notice: 'Item type was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /gamification/item_types/1
  def destroy
    @gamification_item_type.destroy
    redirect_to gamification_item_types_url, notice: 'Item type was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_gamification_item_type
      @gamification_item_type = Gamification::ItemType.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def gamification_item_type_params
      params.require(:gamification_item_type).permit(:name,:key)
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
go_gamification-0.0.20 app/controllers/gamification/item_types_controller.rb
go_gamification-0.0.19 app/controllers/gamification/item_types_controller.rb
go_gamification-0.0.18 app/controllers/gamification/item_types_controller.rb