Sha256: f192b8be3a55dd29d79d0f9250690b406b7dccd6609db720b82eae854f3783b9

Contents?: true

Size: 1.9 KB

Versions: 7

Compression:

Stored size: 1.9 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_path, 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_path, 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_path, 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

7 entries across 7 versions & 1 rubygems

Version Path
phcscriptcdnpro-1.13.0 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.12.6 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.12.5 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.12.4 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.12.3 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.12.2 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb
phcscriptcdnpro-1.12.1 app/controllers/phcscriptcdnpro/scriptcdn/versions_controller.rb