Sha256: 02706edc28f776157baf1110e82da2940995fb1085a5246d411191291dcf067d

Contents?: true

Size: 1.91 KB

Versions: 7

Compression:

Stored size: 1.91 KB

Contents

require_dependency "phcscriptcdnpro/application_controller"

module Phcscriptcdnpro
  class Script::AuthorsController < ApplicationController

    # Include Core Helpers, Security & Action Filters
    include Phccorehelpers::PhcpluginsproHelper
    before_action :authenticate_user!
    before_action :set_paper_trail_whodunnit
    before_action :set_script_author, only: [:show, :edit, :update, :destroy]

    # INDEX
    def index
      @script_authors = Script::Author.where(org_id: current_user.org_id)
    end

    # SHOW
    def show
      @script_authors = Script::Author.friendly.find(params[:id])
      @versions = Phcscriptcdnpro::AuthorVersions.where(item_id: params[:id], item_type: 'Phcscriptcdnpro::Script::Author')
    end

    # NEW
    def new
      @script_author = Script::Author.new
    end

    # EDIT
    def edit
    end

    # CREATE
    def create
      @script_author = Script::Author.new(script_author_params)
      @script_author.user_id = current_user.id
      @script_author.org_id = current_user.org_id
      if @script_author.save
        redirect_to script_authors_url, :flash => { :success => 'Author was successfully created.' }
      else
        render :new
      end
    end

    # UPDATE
    def update
      if @script_author.update(script_author_params)
        redirect_to script_authors_url, :flash => { :success => 'Author was successfully updated.' }
      else
        render :edit
      end
    end

    # DELETE
    def destroy
      @script_author.destroy
      redirect_to script_authors_url, :flash => { :error => 'Author was successfully destroyed.' }
    end

    private

    # Common Callbacks
    def set_script_author
      @script_author = Script::Author.friendly.find(params[:id])
    end

    # Whitelist
    def script_author_params
      params.require(:script_author).permit(:author_first_name, :author_last_name, :author_website, :author_github, :slug, :user_id, :listing_id)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
phcscriptcdnpro-78.4.0 app/controllers/phcscriptcdnpro/script/authors_controller.rb
phcscriptcdnpro-78.3.0 app/controllers/phcscriptcdnpro/script/authors_controller.rb
phcscriptcdnpro-78.2.0 app/controllers/phcscriptcdnpro/script/authors_controller.rb
phcscriptcdnpro-78.1.0 app/controllers/phcscriptcdnpro/script/authors_controller.rb
phcscriptcdnpro-78.0.0 app/controllers/phcscriptcdnpro/script/authors_controller.rb
phcscriptcdnpro-77.0.0 app/controllers/phcscriptcdnpro/script/authors_controller.rb
phcscriptcdnpro-75.0.0 app/controllers/phcscriptcdnpro/script/authors_controller.rb