1 class AttachmentsController < ApplicationController
5 @attachments = Attachment.find(:all)
8 format.html # index.rhtml
9 format.xml { render :xml => @attachments.to_xml }
14 # GET /attachments/1.xml
16 @attachment = Attachment.find(params[:id])
18 respond_to do |format|
19 format.html # show.rhtml
20 format.xml { render :xml => @attachment.to_xml }
24 # GET /attachments/new
26 @attachment = Attachment.new
29 # GET /attachments/1;edit
31 @attachment = Attachment.find(params[:id])
35 # POST /attachments.xml
37 @attachment = Attachment.new(params[:attachment])
39 respond_to do |format|
41 flash[:notice] = 'Attachment was successfully created.'
42 format.html { redirect_to attachment_url(@attachment) }
43 format.xml { head :created, :location => attachment_url(@attachment) }
45 format.html { render :action => "new" }
46 format.xml { render :xml => @attachment.errors.to_xml }
52 # PUT /attachments/1.xml
54 @attachment = Attachment.find(params[:id])
56 respond_to do |format|
57 if @attachment.update_attributes(params[:attachment])
58 flash[:notice] = 'Attachment was successfully updated.'
59 format.html { redirect_to attachment_url(@attachment) }
60 format.xml { head :ok }
62 format.html { render :action => "edit" }
63 format.xml { render :xml => @attachment.errors.to_xml }
68 # DELETE /attachments/1
69 # DELETE /attachments/1.xml
71 @attachment = Attachment.find(params[:id])
74 respond_to do |format|
75 format.html { redirect_to attachments_url }
76 format.xml { head :ok }