Sha256: 09abd5348161ad5e15607c92ddbdfa3e3a91ebc394dc5dbfc8f46e5f67d1c7f5

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require_dependency "policy_manager/application_controller"

module PolicyManager
  class TermsController < ApplicationController
    before_action :set_term, only: [:show, :edit, :update, :destroy]
    before_action :allow_admins
    
    # GET /terms/1
    def show
    end

    # GET /terms/new
    def new
      @term = Term.new
    end

    # GET /terms/1/edit
    def edit
    end

    # POST /terms
    def create
      @term = Term.new(term_params)

      if @term.save
        redirect_to category_term_path(@term.rule.name, @term), notice: I18n.t("terms_app.terms.new.created")
      else
        render :new
      end
    end

    # PATCH/PUT /terms/1
    def update
      if @term.update(term_params)
        redirect_to category_term_path(@term.rule.name, @term), notice: I18n.t("terms_app.terms.new.updated")
      else
        render :edit
      end
    end

    # DELETE /terms/1
    def destroy
      @term.destroy
      redirect_to category_terms_path(@term.rule.name), notice: I18n.t("terms_app.terms.new.destroyed")
    end

    private

    # Use callbacks to share common setup or constraints between actions.
    def set_term
      @term = Term.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def term_params
      params.require(:term).permit(:description, :rule, :state)
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gdpr_rails-0.5.1 app/controllers/policy_manager/terms_controller.rb
gdpr_rails-0.5.0 app/controllers/policy_manager/terms_controller.rb
gdpr_rails-0.4.0 app/controllers/policy_manager/terms_controller.rb
gdpr_rails-0.3.4 app/controllers/policy_manager/terms_controller.rb
gdpr_rails-0.3.3 app/controllers/policy_manager/terms_controller.rb
gdpr_rails-0.3.2 app/controllers/policy_manager/terms_controller.rb