1 class CommentsController < ApplicationController
3 before_filter :login_required, :only => [ :new, :create, :edit, :update, :destroy]
8 @comments = Comment.find(:all)
10 respond_to do |format|
11 format.html { render :xml => @comments.to_xml }
12 format.xml { render :xml => @comments.to_xml }
16 # GET /comments/1 - comments are not accessed individually like this
19 @comment = Comment.find(params[:id])
21 respond_to do |format|
22 format.html { render :partial => 'show', :locals => { :comment => @comment } }
23 format.xml { render :xml => @comment.to_xml }
27 # GET /comments/1;edit
29 @comment = Comment.find(params[:id])
35 @comment = Comment.new(params[:comment])
37 respond_to do |format|
39 flash[:notice] = 'Comment was successfully created.'
40 format.html { redirect_to issue_url(@comment.issue) }
41 format.xml { head :created, :location => comment_url(@comment) }
43 format.html { redirect_to issue_url(@comment.issue) }
44 format.xml { render :xml => @comment.errors.to_xml }
52 @comment = Comment.find(params[:id])
54 respond_to do |format|
55 if @comment.update_attributes(params[:comment])
56 flash[:notice] = 'Comment was successfully updated.'
57 format.html { redirect_to comment_url(@comment) }
58 format.xml { head :ok }
60 format.html { render :action => "edit" }
61 format.xml { render :xml => @comment.errors.to_xml }
67 # DELETE /comments/1.xml
69 @comment = Comment.find(params[:id])
72 respond_to do |format|
73 format.html { redirect_to comments_url }
74 format.xml { head :ok }