Class: BlogPostsController
Overview
The display of a blog is handled by the PagesController and the Page-associated views. This controller is just for adding a blog post via AJAX.
Instance Method Summary
collapse
#current_navable, #current_navable=, #current_user, #point_navigation_to, #redirect_www_subdomain, #set_locale
Instance Method Details
#create ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/blog_posts_controller.rb', line 16
def create
secure_parent.present? || raise('A blog post requires a parent_id to identify the parent page.')
authorize! :create_page_for, secure_parent
@blog_post || raise('No @blog_post created by cancan.')
@blog_post.title = I18n.t(:new_blog_post)
@blog_post.author = current_user
@blog_post.content = "—"
@blog_post.save!
@blog_post.parent_pages << secure_parent
@page = @blog_post
@navable = @blog_post @blog_entries = [@blog_post] @this_is_a_new_blog_post = true respond_to do |format|
format.js
end
end
|
#show ⇒ Object
12
13
14
|
# File 'app/controllers/blog_posts_controller.rb', line 12
def show
redirect_to page_url(id: params[:id])
end
|
#update ⇒ Object
35
36
37
38
39
|
# File 'app/controllers/blog_posts_controller.rb', line 35
def update
set_inheritance_instance_variable
@blog_post.update_attributes params[ :blog_post ].select { |k,v| v.present? && (v != "—")}
respond_with_bip(@blog_post)
end
|