about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/blogs_controller.rb8
-rw-r--r--app/controllers/blogs_controller.rb3
2 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index fa46ab8..9706df3 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb
@@ -2,7 +2,11 @@ class Admin::BlogsController < Admin::AdminController
2 before_action :set_section 2 before_action :set_section
3 3
4 def index 4 def index
5 @blogs = Blog.order(created_at: :desc) 5 @blogs = Blog.where(published: true).order(published_at: :desc)
6 end
7
8 def drafts
9 @blogs = Blog.where(published: false).order(updated_at: :desc)
6 end 10 end
7 11
8 def new 12 def new
@@ -42,7 +46,7 @@ class Admin::BlogsController < Admin::AdminController
42 private 46 private
43 47
44 def blog_params 48 def blog_params
45 params.require(:blog).permit(:title, :body, :slug, records_attributes: [:description, :_destroy]) 49 params.require(:blog).permit(:title, :body, :slug, :published, records_attributes: [:description, :_destroy])
46 end 50 end
47 51
48 def set_section 52 def set_section
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 5e72601..f31287b 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb
@@ -2,6 +2,9 @@ class BlogsController < ApplicationController
2 2
3 def show 3 def show
4 @blog = Blog.find_by_slug(params[:slug]) 4 @blog = Blog.find_by_slug(params[:slug])
5
6 raise ActiveRecord::RecordNotFound unless @blog
7 raise ActiveRecord::RecordNotFound unless @blog.published or user_signed_in?
5 end 8 end
6 9
7end 10end