From e11dedec034c4180985adf4a9f176b07121f0a41 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 4 Jul 2018 11:46:13 -0400 Subject: Blog drafts no longer require slugs They do still technically require titles, but the engine will fill in "Untitled draft" if it is left blank. Unpublished posts can be viewed at a different URL than published posts would be. Quick links to view published and unpublished posts have been added to the admin panel. refs #1 --- app/controllers/admin/blogs_controller.rb | 10 ++++++++++ app/controllers/blogs_controller.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index 9706df3..1035c12 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb @@ -9,6 +9,16 @@ class Admin::BlogsController < Admin::AdminController @blogs = Blog.where(published: false).order(updated_at: :desc) end + def show + @blog = Blog.find(params[:id]) + + if @blog.published + redirect_to blog_url(@blog.slug) + else + render layout: "application" + end + end + def new @blog = Blog.new end diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index f31287b..8ee472e 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -4,7 +4,7 @@ class BlogsController < ApplicationController @blog = Blog.find_by_slug(params[:slug]) raise ActiveRecord::RecordNotFound unless @blog - raise ActiveRecord::RecordNotFound unless @blog.published or user_signed_in? + raise ActiveRecord::RecordNotFound unless @blog.published end end -- cgit 1.4.1