Sha256: 433a4b776899aa85583dedc8e0897ea4286d90a7c758232e9c34779f312f138b

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

require_dependency "phcpress/application_controller"

module Phcpress
	class CategoriesController < ApplicationController

		# Security and Filters
		before_action :authenticate_user!
		before_action :set_category, only: [:edit, :update, :destroy]

		# Categories Index
		def index
			@categories = Category.all
		end

		# New News/Blog Category
		def new
			@category = Category.new
		end

		# Edit News/Blog Category
		def edit
		end

		# Create News/Blog Category
		def create
			@category = Category.new(category_params)

			if @category.save
				redirect_to categories_path, notice: 'Category was Successfully Created.'
			else
				render :new
			end
		end

		# Update News/Blog Category
		def update
			if @category.update(category_params)
				redirect_to categories_path, notice: 'Category was Successfully Updated.'
			else
				render :edit
			end
		end

		# Delete News/Blog Category
		def destroy
			@category.destroy
			redirect_to categories_path, notice: 'Category was Successfully Destroyed.'
		end

		private

		# Common Callbacks
		def set_category
			@category = Category.find(params[:id])
		end

		# Whitelist
		def category_params
			params.require(:category).permit(:catname)
		end

	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
phcpress-3.8.1 app/controllers/phcpress/categories_controller.rb
phcpress-3.8.0 app/controllers/phcpress/categories_controller.rb
phcpress-3.7.9 app/controllers/phcpress/categories_controller.rb
phcpress-3.7.8 app/controllers/phcpress/categories_controller.rb
phcpress-3.7.7 app/controllers/phcpress/categories_controller.rb
phcpress-3.7.6 app/controllers/phcpress/categories_controller.rb
phcpress-3.7.5 app/controllers/phcpress/categories_controller.rb