Mercurial > hg > soundsoftware-site
annotate .svn/pristine/0f/0f71516e3a6532ada8045e94e42972a11451afc4.svn-base @ 976:0befb332f41a get_statistics
get stats up to current date
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Thu, 25 Oct 2012 13:50:45 +0100 |
parents | cbb26bc654de |
children |
rev | line source |
---|---|
Chris@909 | 1 class CommentsController < ApplicationController |
Chris@909 | 2 default_search_scope :news |
Chris@909 | 3 model_object News |
Chris@909 | 4 before_filter :find_model_object |
Chris@909 | 5 before_filter :find_project_from_association |
Chris@909 | 6 before_filter :authorize |
Chris@909 | 7 |
Chris@909 | 8 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } |
Chris@909 | 9 def create |
Chris@909 | 10 @comment = Comment.new(params[:comment]) |
Chris@909 | 11 @comment.author = User.current |
Chris@909 | 12 if @news.comments << @comment |
Chris@909 | 13 flash[:notice] = l(:label_comment_added) |
Chris@909 | 14 end |
Chris@909 | 15 |
Chris@909 | 16 redirect_to :controller => 'news', :action => 'show', :id => @news |
Chris@909 | 17 end |
Chris@909 | 18 |
Chris@909 | 19 verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed } |
Chris@909 | 20 def destroy |
Chris@909 | 21 @news.comments.find(params[:comment_id]).destroy |
Chris@909 | 22 redirect_to :controller => 'news', :action => 'show', :id => @news |
Chris@909 | 23 end |
Chris@909 | 24 |
Chris@909 | 25 private |
Chris@909 | 26 |
Chris@909 | 27 # ApplicationController's find_model_object sets it based on the controller |
Chris@909 | 28 # name so it needs to be overriden and set to @news instead |
Chris@909 | 29 def find_model_object |
Chris@909 | 30 super |
Chris@909 | 31 @news = @object |
Chris@909 | 32 @comment = nil |
Chris@909 | 33 @news |
Chris@909 | 34 end |
Chris@909 | 35 |
Chris@909 | 36 end |