Sha256: 751ec16cc90013e3025d83fac25eba567eb1d2df20021638304707588d575e84

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

module Gamification
  class LevelsController < ApplicationController
    before_action :authenticate_user!, except: [:list, :show_list]
    before_action :authenticate_user!
    load_and_authorize_resource except: [:create]

    # GET /levels
    def index
      @levels = Level.all
    end

    # GET /levels/1
    def show
    end

    # GET /levels/new
    def new
      @level = Level.new
    end

    # GET /levels/1/edit
    def edit
    end

    # POST /levels
    def create
      authorize! :create, @level

      @level = Level.new(level_params)

      if @level.save
        redirect_to @level, notice: 'Level was successfully created.'
      else
        render :new
      end
    end

    # PATCH/PUT /levels/1
    def update
      if @level.update(level_params)
        redirect_to @level, notice: 'Level was successfully updated.'
      else
        render :edit
      end
    end

    # DELETE /levels/1
    def destroy
      @level.destroy
      redirect_to levels_url, notice: 'Level was successfully destroyed.'
    end

    private
    # Use callbacks to share common setup or constraints between actions.
    def set_level
      @level = Level.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def level_params
      params.fetch(:level, {})
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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