app/controllers/phcpresspro/news/posts_controller.rb in phcpresspro-3.0.2 vs app/controllers/phcpresspro/news/posts_controller.rb in phcpresspro-3.0.3
- old
+ new
@@ -2,19 +2,21 @@
module Phcpresspro
class News::PostsController < ApplicationController
# Filters & Security
- layout 'layouts/phcpresspro/newspost/news_layout'
- before_action :require_user
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
@@ -23,11 +25,10 @@
end
# Create News Article
def create
@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
@@ -48,22 +49,17 @@
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_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, :user_id, :category_id)
+ params.require(:news_post).permit(:newspsttitle, :newspsttext, :newspstexcerpts, :pststatus, :pstimage, :remove_pstimage, :category_id, :user_id)
end
end
-end
\ No newline at end of file
+end