about summary refs log tree commit diff stats
path: root/app/controllers/admin/blogs_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin/blogs_controller.rb')
-rw-r--r--app/controllers/admin/blogs_controller.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index 1035c12..35f3514 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb
@@ -13,7 +13,7 @@ class Admin::BlogsController < Admin::AdminController
13 @blog = Blog.find(params[:id]) 13 @blog = Blog.find(params[:id])
14 14
15 if @blog.published 15 if @blog.published
16 redirect_to blog_url(@blog.slug) 16 redirect_to @blog
17 else 17 else
18 render layout: "application" 18 render layout: "application"
19 end 19 end
@@ -25,6 +25,7 @@ class Admin::BlogsController < Admin::AdminController
25 25
26 def create 26 def create
27 @blog = Blog.new(blog_params) 27 @blog = Blog.new(blog_params)
28 @blog.user = current_user
28 29
29 if @blog.save 30 if @blog.save
30 flash.notice = "Blog created successfully!" 31 flash.notice = "Blog created successfully!"
@@ -44,7 +45,7 @@ class Admin::BlogsController < Admin::AdminController
44 def update 45 def update
45 @blog = Blog.find(params[:id]) 46 @blog = Blog.find(params[:id])
46 47
47 if @blog.update_attributes(blog_params) 48 if @blog.update(blog_params)
48 flash.notice = "Blog updated successfully!" 49 flash.notice = "Blog updated successfully!"
49 else 50 else
50 flash.alert = "Error updating blog." 51 flash.alert = "Error updating blog."
@@ -56,7 +57,7 @@ class Admin::BlogsController < Admin::AdminController
56 private 57 private
57 58
58 def blog_params 59 def blog_params
59 params.require(:blog).permit(:title, :body, :slug, :published, records_attributes: [:description, :_destroy]) 60 params.require(:blog).permit(:title, :body, :slug, :published, :published_at, :tag_list, images: [], records_attributes: [:description, :_destroy])
60 end 61 end
61 62
62 def set_section 63 def set_section