Sha256: 58f7f0bead5694bccb487978a9ed9b3ee5a5ad03f9a1b086055f1e901a00d9fe

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

require_dependency "phcscriptcdn/application_controller"

module Phcscriptcdn
  class Script::VersionsController < ApplicationController

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

    # INDEX - Script Versions
    def index
      @script_versions = Script::Version.all
    end

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

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

    # EDIT - Script Versions
    def edit
    end

    # POST - Script Versions
    def create
      @script_version = Script::Version.new(script_version_params)
      @script_version.user_id = current_user.id
      if @script_version.save
        redirect_to script_versions_url, notice: 'Version was successfully created.'
        else
          render :new
      end
    end

    # PATCH/PUT - Script Versions
    def update
      if @script_version.update(script_version_params)
        redirect_to script_versions_url, notice: 'Version was successfully updated.'
        else
          render :edit
      end
    end

    # DELETE - Script Versions
    def destroy
      @script_version.destroy
      redirect_to script_versions_url, notice: 'Version was successfully destroyed.'
    end

    private

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

    # Only allow a trusted parameter "white list" through.
    def script_version_params
      params.require(:script_version).permit(:script_version_number, :slug, :user_id, :org_id)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phcscriptcdn-51.0.0 app/controllers/phcscriptcdn/script/versions_controller.rb
phcscriptcdn-50.0.0 app/controllers/phcscriptcdn/script/versions_controller.rb