Sha256: e3091af680377ad746fddbded12072de536096578a7122a7ce12e6ded507fc76
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
require_dependency "phccodesnipperpro/application_controller" module Phccodesnipperpro class Script::SnippetsController < ApplicationController # Include Core Helpers, Security & Action Filters include PhcdevworksCore::PhcdevPluginsHelper before_action :authenticate_user! before_action :set_script_snippet, only: [:show, :edit, :update, :destroy] # INDEX def index @script_snippets = Script::Snippet.where(org_id: current_user.org_id) end # SHOW def show end # NEW def new @script_snippet = Script::Snippet.new end # EDIT def edit end # CREATE def create @script_snippet = Script::Snippet.new(script_snippet_params) @script_snippet.user_id = current_user.id @script_snippet.org_id = current_user.org_id if @script_snippet.save redirect_to @script_snippet, :flash => { :success => 'Snippet was Successfully Created.' } else render :new end end # UPDATE def update if @script_snippet.update(script_snippet_params) redirect_to @script_snippet, :flash => { :success => 'Snippet was Successfully Updated.' } else render :edit end end # DELETE def destroy @script_snippet.destroy redirect_to script_snippets_url, :flash => { :error => 'Snippet was Successfully Removed.' } end private # Common Callbacks def set_script_snippet @script_snippet = Script::Snippet.find(params[:id]) end # Whitelist def script_snippet_params params.require(:script_snippet).permit(:snippet_title, :snippet_code) end end end
Version data entries
3 entries across 3 versions & 1 rubygems