app/controllers/phcpress/news/posts_controller.rb in phcpress-2.8.11 vs app/controllers/phcpress/news/posts_controller.rb in phcpress-2.8.12
- old
+ new
@@ -6,11 +6,11 @@
class News::PostsController < ApplicationController
# Filters & Security
layout 'layouts/phcpress/newspost/news_layout'
before_action :authenticate_user!
- before_action :current_user?
+ before_action :current_user
before_action :set_news_post, only: [:edit, :update, :destroy]
# News Post Index (/news/posts)
def index
@news_posts = News::Post.all
@@ -66,11 +66,12 @@
def news_post_params
params.require(:news_post).permit(:newspsttitle, :newspsttext, :newspstexcerpts, :pststatus, :pstimage)
end
# Current User
- def current_user?(user)
- user == current_user
+ def current_user
+ return unless session[:user_id]
+ @current_user ||= User.find(session[:user_id])
end
end
end