annotate app/controllers/comments_controller.rb @ 45:65d9e2cabaa3 luisf

Added tipoftheday to the config/settings in order to correct previous issues. Tip of the day is now working correctly. Added the heading strings to the locales files.
author luisf
date Tue, 23 Nov 2010 11:50:01 +0000
parents 40f7cfd4df19
children cbb26bc654de
rev   line source
chris@22 1 class CommentsController < ApplicationController
chris@22 2 default_search_scope :news
chris@22 3 model_object News
chris@22 4 before_filter :find_model_object
chris@22 5 before_filter :find_project_from_association
chris@22 6 before_filter :authorize
chris@22 7
chris@22 8 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
chris@22 9 def create
chris@22 10 @comment = Comment.new(params[:comment])
chris@22 11 @comment.author = User.current
chris@22 12 if @news.comments << @comment
chris@22 13 flash[:notice] = l(:label_comment_added)
chris@22 14 end
chris@22 15
chris@22 16 redirect_to :controller => 'news', :action => 'show', :id => @news
chris@22 17 end
chris@22 18
chris@22 19 verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
chris@22 20 def destroy
chris@22 21 @news.comments.find(params[:comment_id]).destroy
chris@22 22 redirect_to :controller => 'news', :action => 'show', :id => @news
chris@22 23 end
chris@22 24
chris@22 25 private
chris@22 26
chris@22 27 # ApplicationController's find_model_object sets it based on the controller
chris@22 28 # name so it needs to be overriden and set to @news instead
chris@22 29 def find_model_object
chris@22 30 super
chris@22 31 @news = @object
chris@22 32 @comment = nil
chris@22 33 @news
chris@22 34 end
chris@22 35
chris@22 36 end