Sha256: 2ef6e8881439378072ea6603ddecb44c8bb238a165aeeda45ad16e140fd10e2b

Contents?: true

Size: 1.37 KB

Versions: 16

Compression:

Stored size: 1.37 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 Index
		def index
			@articles_posts = Articles::Post.all
		end

		# Article Show
		def show
		end

		# Article New
		def new
			@articles_post = Articles::Post.new

		end

		# Article 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_posts_url, 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_posts_url, 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

		# Params Whitelist
		def articles_post_params
			params.require(:articles_post).permit(:psttitle, :psttext, :pstexcerpts, :pststatus, :pstimage, :remove_pstimage, category_ids: [])
		end

	end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
phcpresspro-4.3.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.3.1 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.3.0 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.12 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.11 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.10 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.9 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.8 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.7 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.6 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.4 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.3 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.1 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.2.0 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-4.1.9 app/controllers/phcpresspro/articles/posts_controller.rb