Class: CommentsController

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

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Instance Method Summary collapse

Methods included from Redmine::MenuManager::MenuController

#current_menu_item, included, #menu_items, #redirect_to_project_menu_item

Methods included from Redmine::Search::Controller

#default_search_scope, #default_search_scopes, included

Methods included from Redmine::I18n

#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages

Instance Method Details

#createObject

Raises:

  • (Unauthorized)

23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/comments_controller.rb', line 23

def create
  raise Unauthorized unless @news.commentable?

  @comment = Comment.new
  @comment.safe_attributes = params[:comment]
  @comment.author = User.current
  if @news.comments << @comment
    flash[:notice] = l(:label_comment_added)
  end

  redirect_to :controller => 'news', :action => 'show', :id => @news
end

#destroyObject


37
38
39
40
# File 'app/controllers/comments_controller.rb', line 37

def destroy
  @news.comments.find(params[:comment_id]).destroy
  redirect_to :controller => 'news', :action => 'show', :id => @news
end