From 55ed70529aefdb3029f5ab72169b2f7909b2f2a3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 10 Dec 2006 18:35:48 +0000 Subject: added model Comment. comments can now be added on news. git-svn-id: http://redmine.rubyforge.org/svn/trunk@81 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/news_controller.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/controllers/news_controller.rb') diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index b50b59dc0..544b6eb8d 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -27,7 +27,23 @@ class NewsController < ApplicationController flash[:notice] = l(:notice_successful_update) redirect_to :action => 'show', :id => @news end + end + + def add_comment + @comment = Comment.new(params[:comment]) + @comment.author = logged_in_user + if @news.comments << @comment + flash[:notice] = l(:label_comment_added) + redirect_to :action => 'show', :id => @news + else + render :action => 'show' + end end + + def destroy_comment + @news.comments.find(params[:comment_id]).destroy + redirect_to :action => 'show', :id => @news + end def destroy @news.destroy -- cgit v1.2.3