add html titles to these pages
[kwestie.git] / app / controllers / attachments_controller.rb
blob799cafa6ad5da9d300ecd10559e2ade1a2ca3ce9
1 class AttachmentsController < ApplicationController
2   # GET /attachments
3   # GET /attachments.xml
4   def index
5     @attachments = Attachment.find(:all)
7     respond_to do |format|
8       format.html # index.rhtml
9       format.xml  { render :xml => @attachments.to_xml }
10     end
11   end
13   # GET /attachments/1
14   # GET /attachments/1.xml
15   def show
16     @attachment = Attachment.find(params[:id])
18     respond_to do |format|
19       format.html # show.rhtml
20       format.xml  { render :xml => @attachment.to_xml }
21     end
22   end
24   # GET /attachments/new
25   def new
26     @attachment = Attachment.new
27   end
29   # GET /attachments/1;edit
30   def edit
31     @attachment = Attachment.find(params[:id])
32   end
34   # POST /attachments
35   # POST /attachments.xml
36   def create
37     @attachment = Attachment.new(params[:attachment])
39     respond_to do |format|
40       if @attachment.save
41         flash[:notice] = 'Attachment was successfully created.'
42         format.html { redirect_to attachment_url(@attachment) }
43         format.xml  { head :created, :location => attachment_url(@attachment) }
44       else
45         format.html { render :action => "new" }
46         format.xml  { render :xml => @attachment.errors.to_xml }
47       end
48     end
49   end
51   # PUT /attachments/1
52   # PUT /attachments/1.xml
53   def update
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 }
61       else
62         format.html { render :action => "edit" }
63         format.xml  { render :xml => @attachment.errors.to_xml }
64       end
65     end
66   end
68   # DELETE /attachments/1
69   # DELETE /attachments/1.xml
70   def destroy
71     @attachment = Attachment.find(params[:id])
72     @attachment.destroy
74     respond_to do |format|
75       format.html { redirect_to attachments_url }
76       format.xml  { head :ok }
77     end
78   end
79 end