Sha256: feaec7b49fb6bb6b66eafd761f6339d03192b4d639149319d20ddbfdd32df7a9

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

require_dependency "phcdevworks_scripts/application_controller"

module PhcdevworksScripts
  class Script::UrlsController < ApplicationController

    # Filters & Security
    #include PhcdevworksCore::PhcpluginsHelper
    before_action :authenticate_user!
    before_action :set_paper_trail_whodunnit
    before_action :set_script_url, only: [:show, :edit, :update, :destroy]

    # INDEX
    def index
      @script_urls = script_listing.urls
    end

    # SHOW
    def show
      @script_url = script_listing.urls.find(params[:id])
    end

    # NEW
    def new
      @script_url = script_listing.urls.build
    end

    # EDIT
    def edit
      @script_url = script_listing.urls.find(params[:id])
    end

    # CREATE
    def create
      @script_url = script_listing.urls.create(script_url_params)
      @script_url.user_id = current_user.id
      @script_url.org_id = current_user.org_id
      if @script_url.save
        redirect_to script_listing_urls_path, :flash => { :success => 'Author was successfully created.' }
      else
        render :new
      end
    end

    # UPDATE
    def update
      @script_listing = Script::Listing.friendly.find(params[:listing_id])
      if @script_url.update(script_url_params)
        redirect_to script_listing_urls_path, :flash => { :success => 'Author was successfully updated.' }
      else
        render :edit
      end
    end

    # DELETE
    def destroy
      @script_url = script_listing.urls.find(params[:id])
      @script_url.destroy
      redirect_to script_listing_urls_path, :flash => { :error => 'Author was successfully destroyed.' }
    end

    private

    # Callback
    def set_script_url
      @script_url = Script::Url.find(params[:id])
    end

    def script_listing
      @script_listing = Script::Listing.friendly.find(params[:listing_id])
    end

    # Whitelist
    def script_url_params
      params.require(:script_url).permit(:cdn_url, :cdn_url_release, :cdn_url_cdn_update, :version_id, :extension_id, :slug, :user_id, :org_id)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcdevworks_scripts-5.8.0 app/controllers/phcdevworks_scripts/script/urls_controller.rb