Sha256: df4221863c300956e0f4f449799bb30a84732d90770021451dc774739a6a8ff1

Contents?: true

Size: 1.87 KB

Versions: 29

Compression:

Stored size: 1.87 KB

Contents

require_dependency "phcscriptcdnpro/application_controller"

module Phcscriptcdnpro
	class Scriptcdn::AuthorsController < ApplicationController

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

		# Author Index
		def index
			scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_authors = scriptcdn_main.authors
		end

		# New Author
		def new
			scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_author = scriptcdn_main.authors.build
		end

		# Edit Author
		def edit
			scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_author = scriptcdn_main.authors.find(params[:id])
		end

		# POST Author
		def create
			@scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_author = @scriptcdn_main.authors.create(scriptcdn_author_params)
			if @scriptcdn_author.save
				redirect_to scriptcdn_main_authors_url, notice: 'Author was successfully created.'
				else
					render :new
			end
		end

		# PATCH/PUT Author
		def update
			if @scriptcdn_author.update(scriptcdn_author_params)
				redirect_to scriptcdn_main_authors_url, notice: 'Author was successfully updated.'
				else
					render :edit
			end
		end

		# DELETE Author
		def destroy
			@scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
			@scriptcdn_author = @scriptcdn_main.authors.find(params[:id])
			@scriptcdn_author.destroy
			redirect_to scriptcdn_main_authors_url, notice: 'Author was successfully destroyed.'
		end

		private

		# Common Callbacks
		def set_scriptcdn_author
			@scriptcdn_author = Scriptcdn::Author.find(params[:id])
		end

		# Whitelist
		def scriptcdn_author_params
			params.require(:scriptcdn_author).permit(:authorfirstname, :authorlastname, :authoremail, :authorgithub, :authortwitter, :main_id)
		end

	end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
phcscriptcdnpro-1.9.4 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.9.2 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.9.1 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.9.0 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.11 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.10 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.9 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.8 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.7 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.6 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.5 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.4 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.3 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.2 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.1 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.8.0 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.7.11 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.7.10 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.7.9 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb
phcscriptcdnpro-1.7.8 app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb