Class: BlogPostsController

Inherits:
PagesController show all
Defined in:
app/controllers/blog_posts_controller.rb

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

Methods inherited from ApplicationController

#current_navable, #current_navable=, #current_user, #point_navigation_to, #redirect_www_subdomain, #set_locale

Instance Method Details

#createObject



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            # this is needed in the BoxHelper in order to show the edit button.
  @blog_entries = [@blog_post]     # this is needed in the BoxHelper in order to hide the attachment box.
  @this_is_a_new_blog_post = true  # in to make the header a link.
  respond_to do |format|
    format.js
  end
end

#showObject



12
13
14
# File 'app/controllers/blog_posts_controller.rb', line 12

def show
  redirect_to page_url(id: params[:id])
end

#updateObject



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