Sha256: 4dedc54121a08a134b7158603ca2f4d4e71f8432eb0cd88c50bb86e3ff294c3a

Contents?: true

Size: 1.35 KB

Versions: 32

Compression:

Stored size: 1.35 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, :pststatus, :pstimage, :remove_pstimage, category_ids: [])
		end

	end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
phcpresspro-5.5.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.5.1 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.5.0 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.4.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.4.1 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.4.0 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.3.4 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.3.3 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.3.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.3.1 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.3.0 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.2.3 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.2.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.2.0 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.1.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.1.1 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.1.0 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.0.3 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.0.2 app/controllers/phcpresspro/articles/posts_controller.rb
phcpresspro-5.0.1 app/controllers/phcpresspro/articles/posts_controller.rb