Sha256: 0e1045c2b203a8ef83861900fd16d611d5c3215171e1d9c3b8744df9d57e0d72

Contents?: true

Size: 1.92 KB

Versions: 64

Compression:

Stored size: 1.92 KB

Contents

require_dependency "phcpresspro/application_controller"

module Phcpresspro
	class Modules::ConnectionsController < ApplicationController

		# Security and Filters
		before_action :require_user
		before_action :membership_info
		before_action :set_modules_connection, only: [:show, :edit, :update, :destroy]

		# Connections Index
		def index
			@modules_connections = Modules::Connection.all
		end

		# Connections Show
		def show
		end

		# Connections New
		def new
			@modules_connection = Modules::Connection.new
		end

		# Connections Edit
		def edit
		end

		# POST
		def create
			@modules_connection = Modules::Connection.new(modules_connection_params)
			@modules_connection.user_id = current_user.id
			@modules_connection.user_name = current_user.username
			@modules_connection.membership_id = membership_info.id
			@modules_connection.oganization_id = membership_info.org_id
			if @modules_connection.save
				redirect_to modules_connections_url, notice: 'Connection was successfully created.'
				else
					render :new
			end
		end

		# PATCH/PUT
		def update
			@modules_connection.user_id = current_user.id
			@modules_connection.user_name = current_user.username
			@modules_connection.membership_id = membership_info.id
			@modules_connection.oganization_id = membership_info.org_id
			if @modules_connection.update(modules_connection_params)
				redirect_to modules_connections_url, notice: 'Connection was successfully updated.'
				else
					render :edit
			end
		end

		# DELETE
		def destroy
			@modules_connection.destroy
			redirect_to modules_connections_url, notice: 'Connection was successfully destroyed.'
		end

		private

		# Common Callbacks
		def set_modules_connection
			@modules_connection = Modules::Connection.find(params[:id])
		end

		# Whitelist
		def modules_connection_params
			params.require(:modules_connection).permit(:post_id, :category_id, :user_name, :user_id, :membership_id, :oganization_id)
		end

	end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
phcpresspro-5.6.2 app/controllers/phcpresspro/modules/connections_controller.rb
phcpresspro-5.6.1 app/controllers/phcpresspro/modules/connections_controller.rb
phcpresspro-5.6.0 app/controllers/phcpresspro/modules/connections_controller.rb
phcpresspro-5.5.8 app/controllers/phcpresspro/modules/connections_controller.rb