Sha256: 831938db0879c74b490d3f5cac087dc3706febf5a24cd199a78b566e2d44c4e7

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

require_dependency "phcscriptcdnpro/application_controller"

module Phcscriptcdnpro
  class Script::VersionsController < ApplicationController

    # Include Core Helpers, Security & Action Filters
    include PhcdevworksCore::PhcdevPluginsHelper
    before_action :authenticate_user!
    before_action :set_paper_trail_whodunnit
    before_action :set_script_version, only: [:show, :edit, :update, :destroy]

    # INDEX
    def index
      @script_versions = Script::Version.where(org_id: current_user.org_id)
    end

    # SHOW
    def show
      @script_versions = Script::Version.friendly.find(params[:id])
      @versions = Phcscriptcdnpro::ScriptversionVersions.where(item_id: params[:id], item_type: 'Phcscriptcdnpro::Script::Version')
    end

    # NEW
    def new
      @script_version = Script::Version.new
    end

    # EDIT
    def edit
    end

    # CREATE
    def create
      @script_version = Script::Version.new(script_version_params)
      @script_version.user_id = current_user.id
      @script_version.org_id = current_user.org_id
      if @script_version.save
        redirect_to script_versions_url, :flash => { :success => 'Version was successfully created.' }
      else
        render :new
      end
    end

    # UPDATE
    def update
      if @script_version.update(script_version_params)
        redirect_to script_versions_url, :flash => { :success => 'Version was successfully updated.' }
      else
        render :edit
      end
    end

    # DELETE
    def destroy
      @script_version.destroy
      redirect_to script_versions_url, :flash => { :error => 'Version was successfully destroyed.' }
    end

    private

    # Common Callbacks
    def set_script_version
      @script_version = Script::Version.friendly.find(params[:id])
    end

    # Whitelist
    def script_version_params
      params.require(:script_version).permit(:script_version_number, :slug, :user_id, :org_id)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phcscriptcdnpro-79.0.3 app/controllers/phcscriptcdnpro/script/versions_controller.rb
phcscriptcdnpro-79.0.2 app/controllers/phcscriptcdnpro/script/versions_controller.rb
phcscriptcdnpro-79.0.1 app/controllers/phcscriptcdnpro/script/versions_controller.rb
phcscriptcdnpro-79.0.0 app/controllers/phcscriptcdnpro/script/versions_controller.rb