comparison .svn/pristine/0f/0f71516e3a6532ada8045e94e42972a11451afc4.svn-base @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents
children
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
1 class CommentsController < ApplicationController
2 default_search_scope :news
3 model_object News
4 before_filter :find_model_object
5 before_filter :find_project_from_association
6 before_filter :authorize
7
8 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
9 def create
10 @comment = Comment.new(params[:comment])
11 @comment.author = User.current
12 if @news.comments << @comment
13 flash[:notice] = l(:label_comment_added)
14 end
15
16 redirect_to :controller => 'news', :action => 'show', :id => @news
17 end
18
19 verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
20 def destroy
21 @news.comments.find(params[:comment_id]).destroy
22 redirect_to :controller => 'news', :action => 'show', :id => @news
23 end
24
25 private
26
27 # ApplicationController's find_model_object sets it based on the controller
28 # name so it needs to be overriden and set to @news instead
29 def find_model_object
30 super
31 @news = @object
32 @comment = nil
33 @news
34 end
35
36 end