Sha256: 0af7c2bf3b8340866d8ae802c99842655e089d8985e2dea55ed0e98830968d69

Contents?: true

Size: 1.87 KB

Versions: 64

Compression:

Stored size: 1.87 KB

Contents

require_dependency "phcpresspro/application_controller"

module Phcpresspro
	class Articles::PostsController < ApplicationController

		# Filters & Security
		before_action :require_user
		before_action :membership_info
		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)
			@articles_post.user_id = current_user.id
			@articles_post.user_name = current_user.username
			@articles_post.membership_id = membership_info.id
			@articles_post.oganization_id = membership_info.org_id
			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
			@articles_post.user_id = current_user.id
			@articles_post.user_name = current_user.username
			@articles_post.membership_id = membership_info.id
			@articles_post.oganization_id = membership_info.org_id
			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, :user_name, :user_id, :membership_id, :oganization_id, category_ids: [])
		end

	end
end

Version data entries

64 entries across 64 versions & 1 rubygems

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