Sha256: ea8a860d9151af61adbdc0df4d13bdc9307895c741a4c2daf3eeb403a9df565e

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

require_dependency "phcpresspro/application_controller"

module Phcpresspro
	class News::PostsController < ApplicationController

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

		# News Post Index
		def index
			@news_posts = News::Post.all
		end

		# Single News Post (/blog/posts/1)
		#def show
		#end

		# New News Article
		def new
			@news_post = News::Post.new
		end

		# Edit News Article
		def edit
		end

		# Create News Article
		def create
			@news_post = News::Post.new(news_post_params)
			if @news_post.save  
				redirect_to news_posts_path, notice: 'News Article was Successfully Created.'
				else
					render 'new'
			end
		end

		# Update News Article
		def update
			if @news_post.update(news_post_params)
				redirect_to news_posts_path, notice: 'News Article was Successfully Updated.'
			else
				render :edit
			end
		end

		# Delete News Destroy
		def destroy
			@news_post.destroy
			redirect_to news_posts_path, notice: 'News Article was Successfully Destroyed.'
		end

		private

		# Common Callbacks
		def set_news_post
			@news_post = News::Post.find(params[:id])
		end

		# Whitelist
		def news_post_params
			params.require(:news_post).permit(:newspsttitle, :newspsttext, :newspstexcerpts, :pststatus, :pstimage, :remove_pstimage, :category_id, :user_id)
		end

	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
phcpresspro-3.0.9 app/controllers/phcpresspro/news/posts_controller.rb
phcpresspro-3.0.8 app/controllers/phcpresspro/news/posts_controller.rb
phcpresspro-3.0.7 app/controllers/phcpresspro/news/posts_controller.rb
phcpresspro-3.0.6 app/controllers/phcpresspro/news/posts_controller.rb
phcpresspro-3.0.5 app/controllers/phcpresspro/news/posts_controller.rb
phcpresspro-3.0.4 app/controllers/phcpresspro/news/posts_controller.rb
phcpresspro-3.0.3 app/controllers/phcpresspro/news/posts_controller.rb