app/controllers/phcpresspro/blog/posts_controller.rb in phcpresspro-2.2.5 vs app/controllers/phcpresspro/blog/posts_controller.rb in phcpresspro-3.0.0
- old
+ new
@@ -1,75 +1,69 @@
-# Load General Controller for Engine
require_dependency "phcpresspro/application_controller"
-# Code for Blog Posting
module Phcpresspro
class Blog::PostsController < ApplicationController
# Filters & Security
- layout 'layouts/phcpresspro/blogpost/blog_layout'
+ layout 'layouts/phcpresspro/newspost/news_layout'
before_action :require_user
- before_action :set_blog_post, only: [:edit, :update, :destroy]
+ before_action :set_news_post, only: [:edit, :update, :destroy]
- # Blog Post Index (/blog/posts)
+ # News Post Index
def index
- @blog_posts = Blog::Post.all
+ @news_posts = News::Post.all
end
- # Single Blog Post (/blog/posts/1)
- #def show
- #end
-
- # Create a New Blog Post (/blog/posts/new)
+ # New News Article
def new
- @blog_post = Blog::Post.new
+ @news_post = News::Post.new
end
- # Edit Blog Post (/blog/posts/1/edit)
+ # Edit News Article
def edit
end
- # Create News Post /news/posts/new
+ # Create News Article
def create
- @blog_post = Blog::Post.new(blog_post_params)
- @blog_post.user_id = current_user.id
- if @blog_post.save
- redirect_to blog_posts_path, notice: 'Blog post was successfully created.'
+ @news_post = News::Post.new(news_post_params)
+ @news_post.user_id = current_user.id
+ if @news_post.save
+ redirect_to news_posts_path, notice: 'News Article was Successfully Created.'
else
render 'new'
end
end
- # PATCH/PUT
+ # Update News Article
def update
- if @blog_post.update(blog_post_params)
- redirect_to blog_posts_path, notice: 'Blog post was successfully updated.'
+ if @news_post.update(news_post_params)
+ redirect_to news_posts_path, notice: 'News Article was Successfully Updated.'
else
render :edit
end
end
- # DELETE
+ # Delete News Destroy
def destroy
- @blog_post.destroy
- redirect_to blog_posts_path, notice: 'Blog post was successfully destroyed.'
+ @news_post.destroy
+ redirect_to news_posts_path, notice: 'News Article was Successfully Destroyed.'
end
private
# Define Current User
def current_user
@_current_user ||= AuthRocket::Session.from_token(session[:ar_token]).try(:user)
end
# Common Callbacks
- def set_blog_post
- @blog_post = Blog::Post.find(params[:id])
+ def set_news_post
+ @news_post = News::Post.find(params[:id])
end
- # Whitelist on what can be posted
- def blog_post_params
- params.require(:blog_post).permit(:blogpsttitle, :blogpsttext, :blogpstexcerpts, :pststatus, :pstimage, :user_id)
+ # Whitelist
+ def news_post_params
+ params.require(:news_post).permit(:newspsttitle, :newspsttext, :newspstexcerpts, :pststatus, :pstimage, :user_id, :category_id)
end
end
end