Sha256: 3607beb0dbdc1aa9b5d0beb2e0422d3e2c75696146194452340f21a75573b417

Contents?: true

Size: 1.89 KB

Versions: 8

Compression:

Stored size: 1.89 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_main_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_main_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_main_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

8 entries across 8 versions & 1 rubygems

Version Path
phcscriptcdnpro-1.12.0 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.12 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.11 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.10 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.9 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.8 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.7 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.11.6 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb