Sha256: 554039e93f7739eace8f78843a2c8517a654eab065fdf626f11335f230d46f41

Contents?: true

Size: 1.84 KB

Versions: 66

Compression:

Stored size: 1.84 KB

Contents

require_dependency "phcpresspro/application_controller"

module Phcpresspro
	class Modules::CategoriesController < ApplicationController

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

		# Categories Index
		def index
			@modules_categories = Modules::Category.all
		end

		# Categories Show
		def show
		end

		# Categories New
		def new
			@modules_category = Modules::Category.new
		end

		# Categories Edit
		def edit
		end

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

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

		# DELETE
		def destroy
			@modules_category.destroy
			redirect_to modules_categories_url, notice: 'Category was successfully destroyed.'
		end

		private

		# Common Callbacks
		def set_modules_category
			@modules_category = Modules::Category.find(params[:id])
		end

		# Whitelist
		def modules_category_params
			params.require(:modules_category).permit(:catname, :user_name, :user_id, :membership_id, :oganization_id)
		end

	end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
phcpresspro-6.7.7 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.7.6 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.7.5 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.7.1 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.7.0 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.9 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.8 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.7 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.6 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.5 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.4 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.3 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.2 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.1 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.6.0 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.5.3 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.5.2 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.5.1 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.5.0 app/controllers/phcpresspro/modules/categories_controller.rb
phcpresspro-6.4.2 app/controllers/phcpresspro/modules/categories_controller.rb