Class: Enki::CommentsController

Inherits:
BaseController show all
Defined in:
app/controllers/enki/comments_controller.rb

Instance Method Summary collapse

Methods included from HostHelper

#render_enki

Methods included from UrlHelper

#author_link, #post_comments_path, #post_path

Methods included from TagHelper

#linked_tag_list

Methods included from PostsHelper

#more_content?

Methods included from PageTitleHelper

#archives_title, #html_title, #page_title, #post_title, #posts_title

Methods included from NavigationHelper

#category_links_for_navigation, #class_for_tab, #page_links_for_navigation

Methods included from FormHelper

#admin_form_for

Methods included from DateHelper

#format_comment_date, #format_month, #format_post_date

Methods included from ApplicationHelper

#author, #comments?, #format_comment_error, #paginated, #tags?

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/enki/comments_controller.rb', line 20

def create
  @comment = Comment.new((session[:pending_comment] || params[:comment] || {}).
    reject {|key, value| !Comment.protected_attribute?(key) })
  @comment.post = @post

  session[:pending_comment] = nil

  if @comment.save
    redirect_to post_path(@post)
  else
    render :template => 'posts/show'
  end
end

#indexObject



6
7
8
# File 'app/controllers/enki/comments_controller.rb', line 6

def index
  redirect_to(post_path(@post))
end

#newObject



10
11
12
13
14
15
16
17
18
# File 'app/controllers/enki/comments_controller.rb', line 10

def new
  @comment = Comment.build_for_preview(params[:comment])

  respond_to do |format|
    format.js do
      render :partial => 'comment', :locals => {:comment => @comment}
    end
  end
end