app/controllers/phccodesnipperpro/script/snippets_controller.rb in phccodesnipperpro-1.0.0 vs app/controllers/phccodesnipperpro/script/snippets_controller.rb in phccodesnipperpro-2.0.0

- old
+ new

@@ -8,11 +8,11 @@ before_action :authenticate_user! before_action :set_script_snippet, only: [:show, :edit, :update, :destroy] # INDEX def index - @script_snippets = Script::Snippet.all + @script_snippets = Script::Snippet.where(org_id: current_user.org_id) end # SHOW def show end @@ -27,29 +27,31 @@ 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.' } + 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.' } + 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 destroyed.' } + redirect_to script_snippets_url, :flash => { :error => 'Snippet was Successfully Removed.' } end private # Common Callbacks