diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-22 16:25:09 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-22 16:25:09 +0000 |
commit | 1f2f9536875a0383f0ac61e0fdd089b666c96070 (patch) | |
tree | 856bfa4645d723b5eb39c754369fa1a00d3ccd86 /app/controllers/comments_controller.rb | |
parent | 3b20774c543d33afe10ff794ee8382f1d8e017e9 (diff) | |
download | redmine-1f2f9536875a0383f0ac61e0fdd089b666c96070.tar.gz redmine-1f2f9536875a0383f0ac61e0fdd089b666c96070.zip |
Refactor: move NewsController#add_comment to CommentsController#create
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4170 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/comments_controller.rb')
-rw-r--r-- | app/controllers/comments_controller.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 000000000..c0d524a25 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,30 @@ +class CommentsController < ApplicationController + default_search_scope :news + model_object News + before_filter :find_model_object + before_filter :find_project_from_association + before_filter :authorize + + verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } + def create + @comment = Comment.new(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 + + private + + # ApplicationController's find_model_object sets it based on the controller + # name so it needs to be overriden and set to @news instead + def find_model_object + super + @news = @object + @comment = nil + @news + end + +end |