Sha256: 14b8163a84046801af07756ab8c891c843acb07eb9e2e092cfcf16f9f75fea06

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

require_dependency "phcpresspro/application_controller"

module Phcpresspro
	class Articles::PostsController < ApplicationController

		# Filters & Security
		before_action :set_articles_post, only: [:show, :edit, :update, :destroy]

		# Article Post Index (/articles/posts)
		def index
			@articles_posts = Articles::Post.all
		end

		# Single Article Post (/articles/posts/1)
		def show
		end

		# Create a New Article Post (/articles/posts/new)
		def new
			@articles_post = Articles::Post.new
		end

		# Edit Article Post (/articles/posts/1/edit)
		def edit
		end

		# POST
		def create
			@articles_post = Articles::Post.new(articles_post_params)

			if @articles_post.save
				@articles_post.connections.build
				redirect_to @articles_post, notice: 'Post was successfully created.'
				else
					render :new
			end
		end

		# PATCH/PUT
		def update
			if @articles_post.update(articles_post_params)
				@articles_post.connections.build
				redirect_to @articles_post, notice: 'Post was successfully updated.'
				else
					render :edit
			end
		end

		# DELETE
		def destroy
			@articles_post.destroy
			redirect_to articles_posts_url, notice: 'Post was successfully destroyed.'
		end

		private

		# Common Callbacks
		def set_articles_post
			@articles_post = Articles::Post.find(params[:id])
		end

		# Whitelists
		def articles_post_params
			params.require(:articles_post).permit(:psttitle, :psttext, :pstexcerpts, :pststatus, :pstcategory, :pstimage, :remove_pstimage, :category_id, :user_id, :membership_id, :oganization_id)
		end

	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
phcpresspro-4.1.6 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.1.5 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.1.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.1.1 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.1.0 app/controllers/phcpresspro/articles/posts_controller.rb