Sha256: 01feb55a34d0c5bf96f46cbaf401bd70585fb6d56c6fdf33c095046c3cd09c8b

Contents?: true

Size: 1.88 KB

Versions: 5

Compression:

Stored size: 1.88 KB

Contents

require_dependency "phcscriptcdnpro/application_controller"

module Phcscriptcdnpro
	class Scriptcdn::VersionsController < ApplicationController

		# Security & Action Filters
		before_action :require_user
		layout '/layouts/phcscriptcdnpro/application.html.erb'
		before_action :set_scriptcdn_version, only: [:edit, :update, :destroy]

		# Script Version Index
		def index
			scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_versions = scriptcdn_main.versions
		end

		# New Script Version
		def new
			scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_version = scriptcdn_main.versions.build
		end

		# Edit Script Version
		def edit
			scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_version = scriptcdn_main.versions.find(params[:id])
		end

		# POST Script Version
		def create
			@scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_version = @scriptcdn_main.versions.create(scriptcdn_version_params)
			if @scriptcdn_version.save
				redirect_to scriptcdn_versions_url, notice: 'Script version was successfully created.'
				else
					render :new
			end
		end

		# PATCH/PUT Script Version
		def update
			if @scriptcdn_version.update(scriptcdn_version_params)
				redirect_to scriptcdn_versions_url, notice: 'Script version was successfully updated.'
				else
					render :edit
			end
		end

		# DELETE Script Version
		def destroy
			@scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_version = @scriptcdn_main.versions.find(params[:id])
			@scriptcdn_version.destroy
			redirect_to scriptcdn_versions_url, notice: 'Script version was successfully destroyed.'
		end

		private

		# Callbacks
		def set_scriptcdn_version
			@scriptcdn_version = Scriptcdn::Version.find(params[:id])
		end

		# Whitelist
		def scriptcdn_version_params
			params.require(:scriptcdn_version).permit(:version, :main_id)
		end

	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
phcscriptcdnpro-1.11.5 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.4 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.2 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.1 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.0 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb